I bought my first Arduino boards in 2007 and never touched them again ever since setting up the famous “blinking LED” code sample. It does recall some memory when I have my hands on the chips and boards and wires and stuff… again.
The Arduino I have is an old NG(Nuova Generazione) rev C, which is later replaced by the most popular “Diecimila”. It comes with a less popular USB Type B port, and tThe user would need to manually click the reset button before uploading the program to the board.
However there’s is still a good thing about it that it does provide a PIN 13 for LED with built-in resister. Hence it requires least effort to setup a minimum “Blinking LED” sample. You don’t even need a breadboard.
Adding digital input is fun. I decided to leave the LED output as is now that it’s working fine with the preset PIN 13, in the good wishes that I would not mess up too much with the breadboard.
B-O-O-M
Check out the video as well!
A small piece of code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | int ledPin = 13; int switchPin = 2; void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin as output pinMode(switchPin, INPUT); } void loop() { if (digitalRead(switchPin)) { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second } } |




Post a Comment