So, I got my first Arduino board, a UNO, on Friday (Thanks Etang Electronics via eBay), costing a smidge under a tenner.
Today was the first time I had to play with it, and the results were good. The free IDE software, downloaded from the main Arduino site here: Arduino on the web is simple and easy to use, and getting my first program uploaded and running was extremely easy.
As a first shot, I simply took some example code from the site, and modified to do my bidding.
The goal was to make the onboard LED flash ‘SOS’, wait 4 seconds, and repeat. My code is below, as it’s good to share 🙂
Go get an Arduino folks, and make stuff, the number of sensors etc is AMAZING! I can see me spending some time with it in the not too distant future.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
// the loop routine runs over and over again forever:
void loop() {
//Signalling SOS with on-board LED
//First S
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(500);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a half second before moving on to O
//Then O
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(1000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(500);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a half second before moving on to the last S
//Finally S again
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, HIGH);Â Â // turn the LED on (HIGH is the voltage level)
delay(250);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for a quarter second
digitalWrite(led, LOW);Â Â Â // turn the LED off by making the voltage LOW
delay(4000);Â Â Â Â Â Â Â Â Â Â Â Â Â Â // wait for 4 seconds before looping again
}