Difference between revisions of "Week 4 Lab"
From Robert-Depot
(→Serial Interface, for debugging) |
(→Serial Interface, for debugging) |
||
| Line 3: | Line 3: | ||
== Serial Interface, for debugging == | == Serial Interface, for debugging == | ||
| + | Sketchbook->Examples->Communication->ASCIITable | ||
| + | |||
Basic text output from the microcontroller, | Basic text output from the microcontroller, | ||
Serial.print() | Serial.print() | ||
and | and | ||
Serial.println() | Serial.println() | ||
| − | |||
| − | |||
Use this to verify values and behavior inside of a program, for debugging. | Use this to verify values and behavior inside of a program, for debugging. | ||
Revision as of 19:34, 20 April 2009
Contents
Interfacing
- Download and install processing http://processing.org/download
Serial Interface, for debugging
Sketchbook->Examples->Communication->ASCIITable
Basic text output from the microcontroller,
Serial.print()
and
Serial.println()
Use this to verify values and behavior inside of a program, for debugging. Examples:
- Displaying values of sensors
Serial.print(val) - Checking program flow.
Dimmer
Examples->Communication->Dimmer Controlling a physical LED with the computer.
modifying for rudimentary keyboard control
void loop()
{
char val;
// check if data has been sent from the computer
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255)
val = Serial.read();
if((val>='0')&&(val<='9'))
analogWrite(ledPin, 25*(val-'0'));
}
}
controlling from a Processing app
See the commented out Processing code at the end of Dimmer example.
- Computer -> Arduino
- Arduino -> Computer
Extra
Connecting to various external devices and components: http://www.arduino.cc/playground/Main/ComponentLib