This piece of code will flash an LED on, output a message that can be read by a serial monitor, then turn it off:
void setup(){
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
Serial.println("RED");
digitalWrite(13,1);
delay(1000);
digitalWrite(13,0);
delay(1000);
}
This can be made more complex by adding another LED and give corresponding output to match:
void setup(){
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
Serial.println("RED");
digitalWrite(13,1);
delay(1000);
digitalWrite(13,0);
Serial.println("BLUE");
digitalWrite(12,1);
delay(1000);
digitalWrite(12,0);
}
Sunday, February 28, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment