工業設計專題資源
上課講義
1. 電路元件
2. 電路設計基礎
3. C語言基礎
RP2040 新增開發板到 Arduino IDE->
額外的開發板管理員網址: (在檔案>偏好設定)
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
RP2040 無法上傳程式碼>
- Unable to build drive list –> 需到windows 環境變數 編輯 path 變數
%SystemRoot%\system32\WBEM
C:\Windows\system32\WBEM
C:\Windows\system32
C:\Windows
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\PowerShell\7\
C:\Windows\System32\OpenSSH\
%UserProfile%\AppData\Local\Microsoft\WindowsApps
LCD1602 paralled 接線圖 ->
LCD1602 paralled 程式碼 ->
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #include <LiquidCrystal.h> LiquidCrystal lcd(9, 8, 7, 6, 5, 4); void setup() { lcd.begin(16, 2); lcd.setCursor(0, 0); lcd.print("HELLO"); } void loop() { }
LCD1602 I2C介面接法 ->
LCD1602 I2C 程式碼 ->
// C++ code // #include <Adafruit_LiquidCrystal.h> //support mcp23008 Adafruit_LiquidCrystal lcd(0); //0x20 address offset 0 void setup() { lcd.begin(16, 2); // initialize the lcd } // setup() void loop(){ lcd.setBacklight(1); //255-->1 lcd.home(); lcd.clear(); lcd.setCursor(0, 0); lcd.print("HELLO WORLD!!!"); lcd.setCursor(0, 1); delay(200); } // loop()
RGB LED 接線圖 ->
RGB LED 程式碼 ->
#define RLED 11 #define BLED 10 #define GLED 9 //https://htmlcolorcodes.com void setup() { // put your setup code here, to run once: pinMode(RLED,OUTPUT); pinMode(GLED,OUTPUT); pinMode(BLED,OUTPUT); } void loop() { // put your main code here, to run repeatedly: analogWrite(RLED,0); analogWrite(GLED,0); analogWrite(BLED,255); delay(100); analogWrite(RLED,0); analogWrite(GLED,255); analogWrite(BLED,0); delay(100); }
Neopixel LED 接線圖->
Neopixel LED 程式碼->
#include <Adafruit_NeoPixel.h> #define PIN 6 #define NUMPIXELS 24 Adafruit_NeoPixel ring24 = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int redColor = 0; int greenColor = 0; int blueColor = 0; void setup() { ring24.begin(); } void loop() { int rColor = random(0, 255); int gColor = random(0,255); int bColor = random(0, 255); for (int i=0; i < NUMPIXELS; i++) { //0-23 24pcs ring24.setPixelColor(i, rColor, gColor, bColor); ring24.show(); } delay(50); }