育秀基金會工作坊
簡介
工作坊
- 一人教,三人協助,20 個學生,一次小時。
- 一人教焊接與寫程式,三人協助,20 個學生,一次小時。
- 分兩組,一人教,一人協助。一組10個學生,一次一小時。
- 分兩組,一人教,一人協助。一組教焊接,一組教程式,一組10個學生,一次一小時。
因為現場變數太大,排四種選項。
教學內容:
- 教 Arduino ,基礎知識,blink、serial port (筆電按鍵按下,13 腳 led 亮)
- 教 Arduino ,基礎知識,blink、焊接光敏電阻,光啟動 led
- 已經把程式碼燒入 Arduino ,焊接光敏電阻,光啟動 led
材料 50 份
- arduino nano mini
- 杜邦線
- 光敏電阻
- 電阻 10k
- led
- 電阻 220
準備工具
- 烙鐵 *8
- 銲錫 *8
- 斜口鉗 *4
- 剝線鉗 *4
- 銅刷 *8
- 延長線
- usb 隨身碟 (已經裝好 arduino , 驅動)
備註
週三下午兩點去場勘
當天決定其中一種方案
程式碼
blink.ino
int led 13;
void setup()
{
pinMode(led, OUTPUT); //set digital pin 13 as OUTPUT
}
void loop()
{
digitalWrite(led, HIGH); //digital pin 13 = HIGH
delay(500); //delay 500 mini seconds
digitalWrite(led, LOW);
delay(500);
}
光敏電阻
---------------------------------------------------------------------------------------------------------------------------
int photocellPin = 2; // 光敏電阻 (photocell) 接在 anallog pin 2
int photocellVal = 0; // photocell variable
int ledPin = 13;
void blinkLED(){
//function body
digitalWrite(ledPin, HIGH);
delay(3000);
digitalWrite(ledPin, LOW);
delay(3000);
}
void setup() {
Serial.begin(9600);
}
void loop() {
// 讀取光敏電阻並輸出到 Serial Port
photocellVal = analogRead(photocellPin);
if ( photocellVal < 300 )
{
blinkLED();
}
Serial.println(photocellVal);
delay(100);
}