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