Code Explanation: /. Anything Written Inside These Symbols Are Not Interpreted As Commands. The Symbol // Is Also Used
Code Explanation: /. Anything Written Inside These Symbols Are Not Interpreted As Commands. The Symbol // Is Also Used
Blink.ino
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
//
//
//
//
Code Explanation
_____________________________________________________________________________________
/*
Blink.ino
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
_____________________________________________________________________________________
This is a comment. Comments are used to document a program. It is enclosed with the symbols /* and
*/. Anything written inside these symbols are not interpreted as commands. The symbol // is also used
in comments. Anything written AFTER these are considered by the sketch as comments.
_____________________________________________________________________________________
void setup() {
_____________________________________________________________________________________
The setup function is the first set of programs to be executed. It is only executed once in the program. It
is usually where the initial configurations of the pins are set-up. { indicates the beginning of the setup
function.
_____________________________________________________________________________________
pinMode(13, OUTPUT);
_____________________________________________________________________________________
The pinMode function is used to configure the pins of the Gizduino. The pins of the Gizduino can be setup
either as a digital INPUT or OUTPUT. On this program, the pin 13 is configured as an output since it will
be connected to a LED. The possible pins that can be used are from pin 0 to pin 13 and pin 14 to pin 21
(A0 to A7).
_____________________________________________________________________________________
}
_____________________________________________________________________________________
} indicates the end of the setup function.
_____________________________________________________________________________________
void loop() {
_____________________________________________________________________________________
The loop function is executed after the setup function. Unlike the setup function, the instructions inside
the loop function are repeated infinitely.
_____________________________________________________________________________________
digitalWrite(13, HIGH);
_____________________________________________________________________________________
The digitalWrite function is used to output an actual value (HIGH or LOW, logic 1 or 0, +5 Volts or 0
Volts) to the pin specified. On this program, a HIGH value (equivalent to +5 Volts) is produced on the pin
13. Forward biasing the LED connected to it, thus, turning it ON. This +5 Volts will stay on pin 13 because
it is latched to the output, unless it is changed by a new value (0 volts).
_____________________________________________________________________________________
delay(1000);
_____________________________________________________________________________________
The delay function produces a time delay in milliseconds. In this program, a time delay of 1000
milliseconds or 1 second is used to see the LED on long enough to observe the blinking effect. The
blinking effect is done by tuning on an LED for a duration of time then turning it off for another duration
of time.
_____________________________________________________________________________________
Conceptual Flowchart