* 目標 [#zea3aa60] #author("2022-01-13T19:14:49+09:00","","") Arduinoを使ってLEDを点滅させよう * 使う物 [#cad16d12] http://arduino.cc/en/uploads/Main/arduino316.jpg - Arduino Duemilanova - ブレッドボード - LED - 抵抗 (220Ω) - PC * インストール [#sf631cf2] - [[ArduinoのIDE:http://www.arduino.cc/]] - Mac OS Xの人はUSBシリアル変換ドライバをインストールする必要があるかも -- [[FTDI Virtual COM Port Drivers:http://www.ftdichip.com/Drivers/VCP.htm]] ArduinoをUSBでPCにつないだあと、 Tools > Serial Port > /dev/tty.usbserial を選ぶ * ブレッドボードにLEDと抵抗を挿す [#yce0ecb9] LEDを3つArduinoにつなぐ あとで誰か書く * プログラムを書く [#h1f218ab] File > Examples > Blink テスとしてアップロード あとは任せた 任された **信号機みたいに青黄色緑で光らせてみよう. [#w060e041] 以下スケッチ例 int redledPin = 5; int yelledPin = 6; int greledPin = 7; // The setup() method runs once, when the sketch starts void setup() { // initialize the digital pins as output: pinMode(redledPin, OUTPUT); pinMode(yelledPin, OUTPUT); pinMode(greledPin, OUTPUT); } // the loop() method runs over and over again, // as long as the Arduino has power void loop() { digitalWrite(redledPin, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(redledPin, LOW); // set the LED off digitalWrite(yelledPin, HIGH); delay(1000); // wait for a second digitalWrite(yelledPin, LOW); digitalWrite(greledPin, HIGH); delay(1000); // wait for a second digitalWrite(greledPin, LOW); } * トラブルシューティング [#hf04423f] - Q: LEDが点かない -- A: LEDの+-の向きはあってる? - Q: LEDが点きっぱなしになったり、点かなかったりする -- A: Pinによって光ったり光らなかったりする。0,1pinはRX,TXだからかな。 -- 教えてえらい人! * 参考URL [#v0f44980] - [[Arduinoリファレンス:http://arduino.cc/en/Reference/HomePage]] - [[Arduino Demilanova:http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove]]