Download Print this page

Intel Galileo Hardware Manual page 8

Biobots
Hide thumbs Also See for Galileo:

Advertisement

Hardware
1.5: Using digitalWrite
Okay, so our program still doesn't actually do anything. (So far, we have only 'setup the pin'.) We need to tell
the microcontroller to actually interact with the LED. A way to do this is a function "
digital
The word '
', in computers, means it can be on or off, low or high, 1 or 0. There are no in betweens
analogWrite
(later you'll see
ting, or making something do something.
digitalWrite
Here's how
digitalWrite(13, HIGH);
digitalWrite
is the function name.
13
'
' is the pin number
HIGH
'
' is the output, which usually means to turn that pin on. The other option is '
the pin off.
Again, we have similar parentheses, commas and semi-colons.
Our overall goal is to get the LED to turn on and off repeatedly so this will go in our "
void setup() {
// put your setup code here, to run once:
//set pin 13 to output, pin 13 is the built-in
LED
}
void loop() {
// put your main code here, to run repeatedly:
}
This is another good time to verify our program. As you get more experience, you can write more without
having to check, but it can get harder to figure out where errors come from.
After making sure the program is correct, we can upload, which is the arrow button
"upload" button moves the program onto the Galileo, from your computer, so that the microcontroller actu-
ally does something.
Some things may blink on the microcontroller as it is uploading, but you should see "upload complete" in
the bottom black window and your LED should turn on.
, which has in-between values). '
might look:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH); //turn on the led
digitalWrite
Writing
' is computer-speak for output-
LOW
loop
".
', which means to turn
" function.
next to verify. The
Hardware 8

Advertisement

loading