Changes

Jump to: navigation, search

Week 4 Lab

542 bytes added, 14:52, 21 April 2009
Serial Basics
== Serial Basics ==
*Open the Sketchbook->Examples->Communication->ASCIITable, compile it, and run it on your processor.
* This program does basic text communication from the processor to your PC.
 
Basic text output from the microcontroller is accomplished with
Serial.print()
You can use this to verify values and behavior inside of a program, for debugging, for example:
 
Displaying values of sensors: <code>
val=analogRead(input_pin);
Serial.print(val);
</code> (assuming you've done the necessary setup).
Checking program flow, communicating the status of things to the user or debugger (you!).  Inside the Arduino software, we will use the "Serial Monitor" to observe what is going on with the serial port. Here is where you will see data printed with the <code>Serial.print()</code> command, and you can also send some very simple messages back to the processor with the "Send" button.  *Open the Sketchbook->Examples->Communication->ASCIITable, compile it, and run it on your processor. * This program does basic text communication from the processor to your PC, running through all of the characters in the alphabet. * With the Serial Monitor, verify that your processor is communicating with the PC (do you see the letters streaming by)
* Assuming you have a sensor which produces an analog output, hook it up to one of the Analog Inputs on your arduino. If you do not have a sensor, use the light sensor from last week. If you are not sure how your sensor works, come over and talk to me and we can try to figure it out.
* Run a short program to read data from that sensor and send it to the Serial port.

Navigation menu