Created
March 31, 2014 21:44
-
-
Save sdbakker/9903059 to your computer and use it in GitHub Desktop.
WdKA basic arduino workshop Part 1: Light an LED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************/ | |
/* Sample useless machine code */ | |
/* WdKA basic arduino workshop */ | |
/* */ | |
/* Part 1: Light an LED */ | |
/* Simon de Bakker <simon@simbits.nl> */ | |
/************************************************************/ | |
/* pin definitions (what is connected to which arduino pin) */ | |
#define LED_PIN 12 | |
void setup() { | |
/* set the directions of each pin */ | |
pinMode(LED_PIN, OUTPUT); | |
/* just a small routine to let us know setup is finished */ | |
/* turn on our LED */ | |
digitalWrite(LED_PIN, HIGH); | |
/* wait half a second */ | |
delay(500); | |
/* turn our LED off again */ | |
digitalWrite(LED_PIN, LOW); | |
} | |
void loop() { | |
/* A local variable to hold the amount of ms to wait */ | |
int wait_ms; | |
/* turn the LED on */ | |
digitalWrite(LED_PIN, HIGH); | |
/* put a random value between 200 and 2000 in wait_ms */ | |
wait_ms = random(10, 500); | |
/* wait for the amount of ms stored in wait_ms */ | |
delay(wait_ms); | |
/* turn the LED off */ | |
digitalWrite(LED_PIN, LOW); | |
wait_ms = random(10, 500); | |
delay(wait_ms); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment