2014年11月24日 星期一

第十一週課堂作業

先拿出一個電路板(大的或小的皆可)
拿出一條USB線,將電腦與電路板相連
電路板綠燈亮!
控制台 > 裝置管理員


看此裝置是com ?

Arduino > Tool > Board
Arduino > Tool > Serial Port

LED燈 短腳(負) , 長腳(正)

先按勾勾再按箭頭執行



LED 5燈連續發光
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeated
  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int a = 13;
int b = 12;
int c = 11;
int d = 10;
int e = 9;
// the setup routine runs once when you press reset:
void setup() {              
  // initialize the digital pin as an outpu
  pinMode(a, OUTPUT);  
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);

}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(a, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(a, LOW);    // turn the LED off by making the voltage LOW
  delay(150);               // wait for a second
  digitalWrite(b, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(b, LOW);    // turn the LED off by making the voltage LOW
  delay(150);               // wait for a second
  digitalWrite(c, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(c, LOW);    // turn the LED off by making the voltage LOW
  delay(150);               // wait for a second
  digitalWrite(d, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(d, LOW);    // turn the LED off by making the voltage LOW
  delay(150);               // wait for a second
  digitalWrite(e, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(150);               // wait for a second
  digitalWrite(e, LOW);    // turn the LED off by making the voltage LOW
  delay(150);               // wait for a second

}


燈泡有循環~~~

沒有留言:

張貼留言