1.模块
MQ3 Alcohol Ethanol, MQ5 methane gas, MQ7 carbon monoxide
DHT11 humidity/temp 20-90RH/0-50C; DHT22(20-90%RH/-40~80C) DHT11 Humidity & Temperature Sensor (mouser.com); HR202 humi w/pot Humidity Sensors and Signal Conditioning Choices | DigiKey; LM35(0~100C)/DS18B20(-55~125C) temp;
DS3231/DS1307 I2C RT clock w/bat
Flame sensor, sound sendor, MPU9150 GYRO crush sensor,knock sensor,tilt motion,sound noise,flame,soil,obastacle,vibration,rain drop,microphone
ultrasonic,joystick,buzzer
photo, voice record
full color RGB LED W2811/2: http://fastled.io/ code in fastled/fastspi lib http://forum.arduino.cc/index.php?topic=333775.0 https://github.com/cpldcpu/light_ws2812 https://learn.adafruit.com/adafruit-neopixel-uberguide
IR remote control,RFID RC522/YW411 (13.56M) RFID系統所使用的頻率,第一種是低頻,範圍在125-134kHz,第二種是高頻13.56 MHz,第三種是超高頻UHF,860-930MHz。http://rfid.ctu.edu.tw/nthu/a/B01C02.pdf https://books.google.com/books?id=EG_hBwAAQBAJ&pg=PA477&lpg=PA477&dq=RFID+的用法
L293/L298 half bridge motor driver 5V stepper w/ ULN2003 driver, TB6612
wifi: ESP12E/F=ESP8266 vs NRF24L01, ESP8266 needs 0.2A power, has shorter distance, but has CPU built in and can be accessed directly on web, NRF24L01 vice versa: http://forum.arduino.cc/index.php?topic=290043.0
XBee, Keyes;
Ethernet: ENC28J60 vs W5100
ENC28J60(cheaper, in Arduino cookbook,10/100/1000M,8KB buffer)/W5100(10/100M,16KB buffer) , 两者都用3.3V0.2A.
W5100+SD module: http://www.ebay.com/itm/Ethernet-Shield-W5100-Arduino-UNO-Mega-2560-1280-AVR-SD-Expansion- https://www.arduino.cc/en/uploads/Main/arduino-ethernet-shield-05-schematic.pdf
Uno 用LP2685只有3.3V150mA直供28J60会死机,可直接代换SOT23 SP3819/BU33SD5WG: https://github.com/ntruchsess/arduino_uip/issues/71 W5100板上MC33269D SOT223够用。
Datasheet:https://www.sparkfun.com/datasheets/DevTools/Arduino/W5100_Datasheet_v1_1_6.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/39662e.pdf
ESP8266 wifi: https://github.com/esp8266/Arduino https://www.sparkfun.com/products/13678
Bluetooth: HC05(m/s)/06(slv only) class2可达10米:https://www.olimex.com/Products/Components/RF/BLUETOOTH-SERIAL-HC-06/resources/hc06.pdf
手机蓝牙连接: http://blog.knownsec.com/2012/02/机器人之旅:当arduino遇上android/
GY-NEO6MV2 GPS http://forum.arduino.cc/index.php?topic=199304.0
2x16LCD: https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/? Gnd/Vcc/Vo(单电阻0.46-1K2接地)/RS/RW/E/D0-7(4bit R4-7)/A/K(back light)。
12832 0.91" OLED
https://startingelectronics.org/tutorials/arduino/modules/OLED-128x32-I2C-display/?
12864 LCD: http://www.arduino.cn/thread-19802-1-1.html
下载到u8glib:https://github.com/olikraus/U8glib_Arduino/releases/latest或
http://clz.me/u8glib/,将类库存放到Arduino IDE下的libraries文件夹中,便可正常使用。成员函数介绍:https://github.com/olikraus/u8glib/wiki或http://clz.me/u8glib/ 你应该先确定其使用的控制芯片型号,然后在u8glib项目的设备支持页(https://github.com/olikraus/u8glib/wiki/device 或 http://clz.me/u8glib/device/ ),找到你使用的设备对应的类及其构造函数,并使用它新建一个LCD操作对象。
2. Android开发:
http://www.aemn.pt/formacao/Arduino/DVD_tutorial%20-%20Arduino/arduino%20eBook%20Collection/Professional%20Android%20Open%20Accessory%20Programming%20with%20Arduino.pdf
https://blog.arduino.cc/2013/07/18/how-to-control-arduino-board-using-an-android-phone/
All you need to know about Amarino
Arduino and Android using MIT app inventor 2.0
.wav player: in book "Arduino cookbook"
https://www.instructables.com/id/GSMGPRS-Module-DIY-Kit/
https://www.instructables.com/id/Arduino-Bluetooth-Basic-Tutorial/
https://www.instructables.com/id/Beginner-Arduino-Using-a-18-Inch-TFT-Display/
FreeRTOS:https://exploreembedded.com/wiki/Setting_Up_FreeRTOS_on_Arduino https://www.arduinolibraries.info/libraries/free-rtos it needs Atmeg2560
更新:ATmega32U4全面超过ATmega328,带USB,更多路10bit A/D带差分。类似Uno的叫Leonardo,类似nano的叫Arduino Micro或Pro Micro。Atmeg
2560: https://item.taobao.com/item.htm?id=665777542501 链接: https://pan.baidu.com/s/1rHZpIhrEUeGheqjZRtQFWA
提取码:ze47 atmeg32U4:https://item.taobao.com/item.htm?id=620621802305 https://item.taobao.com/item.htm?id=637768632781
用Nano的自动温控风扇:https://www.youtube.com/watch?v=aox-nf5UiLM
//CONFIG ===========================================
#define aref_voltage 3.3 // we tie 3.3V to ARef and measure it with a multimeter!
//TMP36 Pin Variables
int tempPin = 0; // TMP36 Center lead to Analog Pin [A1-A7] (Elegoo Nano v.3)
int tempReading; // the analog reading from the sensor
//Relay Pin Variable
int relayPin = 2; // Relay Singnal lead to Digital Pin [D2-D12] (Elegoo Nano v.3)
//Tempurature Range
// Its good to provide a buffer for efficiency, if the temp bounces from 79-81 constantly
// it will turn on and off the fan constantly. So set a minimum temperature that the fan
// can cool the are too before it starts checking for max temperature.
float maxTemperature = 80.00; // The Max Temperature allowed
float minTemperature = 75.00; // The Min Temperature allowed
//===================================================
void setup() {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
// If you want to set the aref to something other than 5v
analogReference(EXTERNAL); // Feed the 3.3v cable back into the AREF pin
// Pin Setup/Register
pinMode(relayPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
float temperature = getTemperature();
if(temperature >= maxTemperature){
powerOnRelay();
} else if (temperature <= minTemperature) {
powerOffRelay();
}
delay(1000); // Check tempertature every second
}
void powerOnRelay() {
digitalWrite(relayPin, HIGH);
Serial.println("Relay On");
}
void powerOffRelay() {
digitalWrite(relayPin, LOW);
Serial.println("Relay Off");
}
float getTemperature(){
tempReading = analogRead(tempPin);
float voltage = tempReading * aref_voltage;
voltage /= 1024.0;
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset to degrees ((volatge - 500mV) times 100)
//Serial.print(temperatureC); Serial.println(" degrees C"); // For debuging purpouses
// now convert to Fahrenheight
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
// Choose which tempurature you would like to use.
return temperatureF; //Fahrenheight
//return temperatureC; // Celcius
}
开发实例:https://www.youtube.com/watch?v=R102xfcx75I#t=11m 硬件是Nano其在脚13接有LED,高电平点亮。去arduino.cc下载windows版,安装运行;在tool里选板子nano、处理器328P、串行端口号;编辑下述语句:
void setup() {
pinMode(13, OUTPUT); // sets the digital pin 13 as output
}
void loop() {
digitalWrite(13, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(13, LOW); // sets the digital pin 13 off
delay(1000); // waits for a second
}
项目中选编译,成功后上载,即可在Nano版上看到LED闪烁。
CNC板:https://www.geek-workshop.com/thread-39359-1-6.html
2.2 用ARDUINO开发ESP32:
https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/ 在File|Preference的URL填入https://dl.espressif.com/dl/package_esp32_index.json,在Tools|Board里搜索Esp32安装即可。
3.Arduino多任务
https://blog.wenxuecity.com/myblog/36867/202212/1445.html
3.1Nano 33 BLE
是Arduino Nano的3.3V兼容板,45x18mm!它用nRF52840,含64MHz 32bit ARM® Cortex®-M4 CPU($24 M0: https://store-usa.arduino.cc/products/arduino-nano-33-iot?selectedStore=us)、1MB Flash, 256KB RAM, Bluetooth 5.3、超低功耗模式。Nano 33 BLE带有LSM9DS1 惯性测量单元(IMU),即包括加速度计/陀螺仪/磁力计的3轴,由ArduinoBLE库支持。这使得它成为机器人实验、运动追踪器、数字罗盘等的完美选择,价格约26.5刀。nRF52840 USB Dongle约10刀。
https://store-usa.arduino.cc/products/arduino-nano-33-ble?selectedStore=us
https://download.e-bookshelf.de/download/0014/3270/05/L-G-0014327005-0050496274.pdf
https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/product-briefs/nrf52840-soc-v3.0.pdf
https://www.digikey.com/en/maker/blogs/2022/how-to-write-multi-threaded-arduino-programs
3.2 ATMEGA328
汇编的话,LD/ST指令可以在寄存器包括堆栈和存储器间交换数据:https://create.arduino.cc/projecthub/patrick-fitzgerald2/explore-avr-assembly-language-9619b6
https://code.google.com/archive/p/arduino-scoop-cooperative-scheduler-arm-avr/downloads? 这个SCoop很旧了,2-3个任务的话较方便。例子:
#include “SCoop.h” // create an instance of the scheduler called mySCoop
defineTask(Task1) // user definition of task1 object
volatile long count; // force any read/write to memory
void Task1::setup() { count=0; };
void Task1::loop() { sleepSync(1000); count++; };
defineTaskLoop(Task2) // user quick definition of task2 object
{ digitalWrite(13, HIGH); sleep(100); digitalWrite(13,LOW); sleep(100); }
void setup() { Serial.begin(115200); mySCoop.start(); }
void loop() { long oldcount=-1; yield();
if (oldcount!=count) { Serial.print(“seconds spent :”);
Serial.println(count); oldcount=count; } }
Mthread lib: GitHub - arduino-libraries/Arduino_Threads: Simple thread-safe IO for parallel sketch execution. [BETA]
4. 调试与PCB
4.1 ICE/OCD
https://www.aliexpress.com/i/2255800017220914.html V9速度加倍可达20M,适合1.2-3.3V/5V目标板。链接用uVision软件。最廉价$22.32:https://www.aliexpress.us/item/2251832669465170.html
4.2 仿真
https://all3dp.com/2/best-arduino-simulators-online-offline:
Tinkercad Circuits是 Autodesk 于 2017 年开始提供的一项免费在线服务,可能是用户最友好的 Arduino 模拟器。您可以轻松设计自己的电路,以块或文本格式创建程序,然后对其进行调试。Arduino板卡和IO接口的仿真以及与代码的交互效果非常好,代码可以下载并与其他创客共享。Tinkercad 不允许您创建或添加自己的零件和组件,现有的库有限,但可绕过:https://www.youtube.com/watch?v=id2Q-N3YmKU? 就是把库解压缩得到源码加到你的源文件里。想用 Tinkercad需要加入,选择教育者、学生或个人帐户。
SimulIDE是一款具有 PIC、AVR 和 Arduino 仿真功能的电子线路仿真器。可以设计自己的电路并使用适用于 GcBasic、Arduino、PIC 和 AVR 的代码编辑器和调试器对其进行编程,但不能创建自己的部件或组件(尽管您可以在论坛或 Patreon 上提问)。有YouTube 频道。
PICSimLab是开发板的实时仿真器,带有集成的 MPLAB X/AVR-GDB 调试器。它支持一些 PICSim 微控制器和一些 Simavr (ATMEG328/2560 etc)微控制器。PICSimLab 与 MPLAB X Arduino IDE 集成,用于对微控制器板进行编程。您可以设计自己的电路、加载 HEX 文件或直接从 Arduino IDE 上传。您还可以模拟 Arduino I/O 接口和程序交互。高级用户可以创建或添加自己的零件和组件。
Arduino IO Simulator不是“真正的”Arduino Simulator(正如您从常见问题解答中看到的那样),但它仍然值得一提。它由 20 岁的 Louis D'Hont 开发,最初只是一个业余爱好项目。目前,它被 25,000 名修补匠使用,其中包括许多学校和公司。要使用该软件,您需要一个Arduino Uno,该软件负责输入和输出模拟。此外,您必须将 Xevro 库添加到您的 Arduino 草图中(示例此略),目前Pro版也免费: https://xevro.be/products/arduino-simulator-windows-free.html? 许可证密钥:5FVKL-CMSM2-ZH9EX-UAFIX-AKRN9 或者:FLEAK-4VBAA-TDZ4E-A3LKC-FX9HR 内置组件:14 个 LED 4 种颜色、8个按钮、方波发生器、蜂鸣器(频率可调)、噪音检测(麦克风)、3 个滑块、7段显示、16x2液晶显示、条形图、音调、声音发生器(频率可变)、伺服电机、串行监视器。在 Arduino IDE 中编写您的项目。添加模拟器库,你就完成了。将代码上传到 Arduino 板。在模拟器中选择您的输入和输出。也可以在屏幕上模拟IO,同时控制真实IO。为了让模拟器理解代码,我们更改了库以与我们的模拟器兼容。为了保持可用性,我们决定保留所有说明,您只需添加模拟器库即可进行模拟。
Fritzing不是 Arduino 模拟器,而是电子设计自动化 (EDA) 软件。在其中,您可以设计自己的电路,创建和添加自己的零件和组件,以及为 PCB 生产编程和导出电路板和原理图。他们网站上的广泛学习部分将帮助您前进。
4.3 免费PCB设计
5 项目备忘
5.1 泊车辅助灯:最早的测距是悬挂乒乓球,当其接触前玻璃时停车。这里是超声探头测量距离,改变灯数目/颜色(全绿/半绿/单黄/全红,代码可改动以便在超越距离时红灯闪烁),由开门器灯泡电源供电,需调整距离常数和探头高低。探头HC-SR04,5V15mA,2-400cm: https://projecthub.arduino.cc/Bcjams/55c22c45-38e6-4b26-8a8c-30ec973d808f。同理可置于侧面下部,以在反光镜前提示偏向;或者红外灯组连uP都可省去。
4.4 ATtiny85
8K flash, 512B EEprom, 可借用nano来编程:https://www.youtube.com/watch?v=Z_MhVSlMZI8 先在File|Preference下键入:http://drazzy.com/package_drazzy.com_index.json Ok,再Tools|Board|Boards manager键入attiny安装core。Program using Uno: https://www.circuits-diy.com/oled-i2c-with-attiny85-hello-world-program 可运行多任务:https://www.electrosoftcloud.com/en/arduino-taskscheduler-no-more-millis-or-delay programming using USB: https://circuitdigest.com/microcontroller-projects/attiny85-ic-programming-through-usb-using-digispark-bootloader
general info: https://www.studiopieters.nl/attiny85-oled-i2c/
0.96" oled 128x64 lib: https://www.arduinolibraries.info/libraries/tiny4k-oled
hard coded lib/app: https://www.instructables.com/ATTiny85-connects-to-I2C-OLED-display-Great-Things/
new: https://forum.arduino.cc/t/using-the-small-oled-128x64/1026447
2key using AD0: 假设uP内上拉50K,用单线8bit ADC接三个电阻均15K,两按键S1、S0,同时按下为S2,5V供电,则有:if v<=128 key=s0 elif v<=164 key=s2 elif v<=220 key=s1 else key=0;
机油压力表:pin 1-8=PB5/ADC0, PB3/ADC3, PB4/ADC2, GNG, PB0/SDA, PB1, PB2/SCL, VCC. PB1=Alarm,PB4=Oil Psi,PB3=key,PB5=GasPsi
木工房电器与自控 https://blog.wenxuecity.com/myblog/36867/201408/20593.html