Arduino
来自Jack's Lab
目录 |
1 总览
I2S 总线精要
2 扩展
MC105 可燃气体传感器
Geiger 盖格计数器
热感相机:Adafruit AMG8833 IR Thermal Camera https://www.adafruit.com/product/3622
Arduino Ethernet 的另一性价比选择 W5500 Ethernet Shield v1.0
Encoder 旋转编码器
Digipot 数字电位器
Relay 继电器
Optocoupler 光耦
3 应用
4 精华
5 MCU
5.1 LGT8F08/88/328 (AVR Compatible)
5.2 LGT8F684/690, LGT8P653/663 (PIC Compatible)
5.3 STM32
6 糖豆
6.1 float2str
String(NUMBER, SCALE); String(3.141592,5); # "3.14159"
6.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()); }
6.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; } } }
6.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; }
7 资源
- 二极管选型指南:http://www.vishay.com/docs/49627/49627.pdf
- 将电解电容器更换为MLCC的指南
- MCU 3V Tips
- 電容器阻抗/ESR頻率特性
- 低压差调节器—为什么选择旁路电容很重要
- 精算陶瓷電容性能表現
- http://www.robopeak.com/blog/?p=107
- spi flash: http://forum.arduino.cc/index.php?topic=178462.0
- http://www.avrfreaks.net/forum/winbond-spi-flash-library-avr-arduino-written-c
- avr-libc user manual: http://www.nongnu.org/avr-libc/user-manual/modules.html
8 Notes
9 Reference
- HTTP Spec: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
- https://zh.wikipedia.org/wiki/ASCII