Thursday, February 25, 2010

Task 22 - program: two leds of different colours and output the colour of the led to the screen each time it goes on.

//program: two leds of different colours and output the colour of the led to the screen each time it goes on.
// by Adam Randall

int ledPin = 12;
int greenLedPin = 13;

// The setup() method runs once, when the sketch starts


void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
pinMode (greenLedPin, OUTPUT);
Serial.begin(9600);
}


void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
digitalWrite(greenLedPin, LOW); // set the LED off
Serial.println("Yellow");// shows the word yellow on screen
delay(200);
digitalWrite(ledPin, LOW); // set the LED off
digitalWrite(greenLedPin, HIGH); // set the LED on
Serial.println("Green");// shows the word green on screen
delay(200);


}

No comments:

Post a Comment