Assignment: Introduction to Arduino and Physical Computing
Collaborators:
Description
This program causes the led to run for 3 seconds, then pause 3 seconds, run for 2 seconds then pause for 2 seconds, run for 1 second then pause for 10 seconds. After this pause the loop begins again.
Components Used
- Light Emitting Diode (LED)
- Resistor
Arduino Code
/* 3- 2- 1-Done: Blinking LED
* ------------
*
* This program causes the led to run for 3 seconds, then pause
* 3 seconds, run for 2 seconds then pause for 2 seconds, run
* for 1 second then pause for 10 seconds. After this pause the
* loop begins again.
*
* Created 7 September 2009
* by George T Hayes
*/
int ledPin = 13; // LED connected to digital pin 13
int time_stamp = 1000; // Incrementing in steps of 1 sec
//One sec is 1000 millisec
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
// Happens only at the start of the simulation
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
//Power to the board comes from the USB2Serial converter
//The voltage of pulse from Pin13 is dropped over a resitor and given to the LED
void loop() // This is an infinite loop
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(3000); // on for 3 seconds
digitalWrite(ledPin, LOW); //Set the LED pin to OFF
delay(3000); // off for 3 second
digitalWrite(ledPin, HIGH); // set the LED on
delay(2000); // on for 2 seconds
digitalWrite(ledPin, LOW); //Set the LED pin to OFF
delay(2000); // off for 2 second
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // on for 1 seconds
digitalWrite(ledPin, LOW); //Set the LED pin to OFF
delay(10000); // off for 10 seconds
}
Image