02 March 2010

Blink 3a Arduino board - 2 external LEDs, different timings

/*
* Project: blink3a
* Author: Jane-Maree Howard
* Date: Tuesday 02/03/2010
* Platform: Arduino 18
* Purpose: To demonstrate variable blink times for the built-in LED & external LEDs
* Operation: Sets up output pins (3 off) in setup() method;
* Declares pin definition variables (3 off)
* Defines loop() to perform various LED blinking & delay operations
*/

int ledPin = 13; // on-board LED connected to digital pin 13
int ylwLedPin = 12; // yellow LED connected to digital pin 12
int redLedPin = 11; // red LED connected to digital pin 11
int dLay = 1000; // delay variable
// The setup() method runs once, when the sketch starts
void setup()
{
// initialize the 3 digital pins as outputs:
pinMode(ledPin, OUTPUT);
pinMode(ylwLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
// turn them all on
digitalWrite(ylwLedPin, HIGH); // turn yellow LED on
digitalWrite(redLedPin, HIGH); // turn red LED on
digitalWrite(ledPin, HIGH); // turn on-board LED on
delay(dLay*8); // delay 8 seconds
}//end setup()

// Loop turns pin13 (LED) on, waits one second, turns LED off, waits briefly ;
// repeats endlessly while Arduino has power
void loop()
{
digitalWrite(ylwLedPin, LOW); // turn yellow LED off
digitalWrite(redLedPin, LOW); // turn red LED off
delay(4*dLay); // delay 4 seconds
digitalWrite(ledPin, HIGH); // turn on-board LED on
delay(4*dLay); // wait for 4 seconds
digitalWrite(ylwLedPin, HIGH); // turn yellow LED on
digitalWrite(redLedPin, HIGH); // turn red LED on
delay(dLay); // delay 1 seconds
digitalWrite(ledPin, LOW); // turn on-board LED off
delay(3*dLay); // wait for 3 seconds
}//end loop()

2 comments:

  1. ..AND the post does its usual thing with punctuation (OR NOT in this case :-[ )

    I just haven't worked how how to make it post TIDILY!!

    ReplyDelete
  2. I tried copying & pasting the above post straight into an Arduino sketch-pad {siigh}..

    Yes - I COULD go thru it all & insert 'hard' breaks into the sketch, but that would take longer than I can be bothered with..

    ..I could rewrite the damn thing in that time

    ReplyDelete