-
Notifications
You must be signed in to change notification settings - Fork 31
Code Examples
zacinaction edited this page Jan 28, 2013
·
27 revisions
One of the most useful things when you're debugging your code is the ability to send data from the microcontroller back to your PC. To do this we'll use the Serial class. Here's a quick example (which you can download here):
/*
SerialDemo
Demonstrates the use of the Serial port for sending information
back to the host PC
*/
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello Earthlings\n");
delay(1000);
}
Basically, you'll need to call Serial.begin(9600);
in your setup function, then any time you'd like to send data back, call Serial.println("Put stuff here");
.
After you compile and upload the code onto the Sprite, click the "Serial Monitor" button in the top right corner of the Energia window to read what's being sent over the serial connection.