top of page

Writing Code (Cont.)

Using the 'Blink' example (In the IDE, in the upper left corner, click: 'File'->'Examples'->'01. Basics'->'Blink'), you can see the two functions described on the previous page.  

In the 'Setup' function, the code declares pin 13 as an output pin, by calling the 'pinMode()' function. This is a built-in function used by Arduino to instruct the processor on how to use it's pins.  In this case, pin 13 is declared as an output pin. 

In the 'Loop' function, the code uses 'digitalWrite(13, HIGH)' to write a value to a pin on the board.  'digitalWrite' is another built-in function of Arduino that simply means 'output the value to the pin specified'(write 'HIGH' to pin 13). 'HIGH' = 5 volts  'LOW' = 0 volts.

The next line of code 'delay(1000);' causes the processor to delay for 1 second(The delay function is written in units of milliseconds. 1000ms = 1 sec). 

The final two lines are a repeat of the first two, except it writes a 'LOW' to pin 13 instead of a 'HIGH'.  This causes pin 13 to be 'HIGH' for one second, and then 'LOW' for one second. 

*** Tutorial Point: Every valid line of code MUST end with a semicolon character(' ; ') for the processor to consider it as an instruction and attempt to read it. The line with three blue dots above is an example.
bottom of page