Download Print this page

Intel Galileo Hardware Manual page 33

Biobots
Hide thumbs Also See for Galileo:

Advertisement

Hardware
>AutoFormat to make your code look nicer.
Use comments
use comments for anything weird, potentially confusing, or a problem area.
Don't write your program all at once
Make sure you can tell if a part of it is working. If you know each part is working, the only type of errors
will be found while putting them together, which is a lot less.
Test often
Look at similar examples using the internet, or the built-in examples (file->examples).
Write it out
connect the parts with arrows.
Diagnosing
- Logical errors are hard to find. If your program just doesn't work right, even if it uploads fine.
Some approaches to find logical errors:
Write it out again
program look the same?
Comment out a problem line
pens, when you remove some line?
Print out program information
information, not print it out on paper. A microcontroller can print variable names, or text to the console
in the following way:
void setup{
want to use the serial port
}
void loop{
be on the same line
ing Serial.print, to prevent backup
}
Start by writing comments after every line of code. As you gain more experience,
- Not sure how a part of your code should work? Make a separate program to test it.
- Write out, by hand, how the program is supposed to work. Put each part in a box, and
- Go through how it's supposed to work again, does it make sense? Does the
Serial.begin(9600); //tells the microcontroller that you
int myNumber = 0;
Serial.println("I am looping!!"); //print a line
Serial.print("My number is: "); //These two things will
Serial.print(myNumber);
myNumber++; //Add one to myNumber
delay(500); //Include a delay of at least 10ms when us-
Break your program into smaller, testable blocks.
- Try to see if a specific line is causing a problem. What hap-
- The word 'print' in computer programming is to output text
Hardware 33

Advertisement

loading