Arduino

来自Jack's Lab
2021年1月19日 (二) 14:23Comcat (讨论 | 贡献)的版本

跳转到: 导航, 搜索

目录

1 总览

Arduino I/O 之数字输入输出

Arduino I/O 之模拟输出

Arduino I/O 之数字输出扩流

Arduino memory

深入 PWM

撰写自己的 Arduino 库


阻抗和阻抗匹配

晶振电路

SPI 总线精要

I2C 总线精要

I2S 总线精要

UART 体系结构



2 扩展

DHT21/AM2301 数字温湿度传感器

DHT11 数字温湿度传感器

SHT2x 数字温湿度传感器

PT100/PT1000 工业级温度传感器


扩散硅工业级压力传感器

MC105 可燃气体传感器

烟雾传感器

风速传感器

漏水传感器


PIR 热释红外传感器,人体感应

Geiger 盖格计数器

Ultrasonic


夏普 GP2Y1010AU0F 灰尘传感器

PPD42NS Dust Sensor

PT550 光敏二极管光线传感器

BH1750 光线传感器


热感相机:Adafruit AMG8833 IR Thermal Camera https://www.adafruit.com/product/3622


SSD1306 OLED 显示屏

ILI9341 TFT 显示屏


Arduino Ethernet 的另一性价比选择 W5500 Ethernet Shield v1.0

RS485

MBus

RFID

LoRa

GPS


Encoder 旋转编码器

Digipot 数字电位器

Relay 继电器

Optocoupler 光耦

ADC


MEMS Mic


FT2232


LEON3



3 应用

Arduino 监控客厅温度湿度



4 精华

Arduino bootloader 的烧写

面包板上的至简 Arduino

动手焊一个自己的 Arduino

Arduino 低功耗优化

ATtiny13

Eagle Tips

Raspberry

Modbus

DLT645

CJT188

Tesla

Power



5 Notes


PCB 板材参数



6 MCU

6.1 LGT8F08/88/328 (AVR Compatible)

Atmega328p-TQFP32-pin.jpg


6.2 LGT8F684/690, LGT8P653/663 (PIC Compatible)



6.3 STM32

Stm32-cata.jpg



6.4 STM8

STM8S105K-QFP32-pinmap.jpg



6.5 ATmega328

Atmega328p-TQFP32-pin.jpgHEX-328-sch.jpg


7 I2C pin

Board	         I2C / TWI pins
----------------------------------
Uno, Ethernet	A4 (SDA), A5 (SCL)
Mega2560	    20 (SDA), 21 (SCL)
Leonardo   	    2 (SDA), 3 (SCL)
Due       	    20 (SDA), 21 (SCL), SDA1, SCL1



7.1 ATtiny13



8 糖豆

8.1 float2str

String(NUMBER, SCALE);
String(3.141592,5);        # "3.14159"



8.2 Software Serial

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // set the data rate for the SoftwareSerial port
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
}

void loop()
{
  if (mySerial.available())
    mySerial.write(Serial.read());
}



8.3 AT CMD

SerialEvent() is called after a loop(), if there is serial data in the buffer.

String input_str = "";              // a string to hold incoming data
boolean str_over = false;           // whether the string is complete

void setup() {
  Serial.begin(9600);
  input_str.reserve(200);           // reserve 200 bytes for the inputString:
}

void loop() {
  if (str_over) {
    // Identify the CMD and processing

    input_str = "";                 // clear the string buffer
    str_over = false;
  }
}

/*
 * SerialEvent occurs whenever a new data comes in the hardware serial RX.
 * This routine is run between each time loop() runs, so using delay inside
 * loop can delay response.  Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    char in = (char)Serial.read(); 
    input_str += in;

    if (in == '\n') {                // read a line into string buffer
      str_over = true;
    } 
  }
}



8.4 Hex str to ull

char hexstr2bin(char c) {
 if (isdigit(c)) {  // 0 - 9
   return c - '0';
 } else if (isxdigit(c)) { // A-F, a-f
   return (c & 0xF) + 9;
 }
 return -1;
}

unsigned long long hexstr2ull(char * string)
{
  unsigned long long x =0;
  char c;
  do {
    c = hexstr2bin(*string++);
    if (c < 0)
      break;
    x = (x << 4) | c;
 } while (1);
 return x;
}



9 资源




10 Reference













个人工具
名字空间

变换
操作
导航
工具箱