Difference between revisions of "Week 4 Lab"

From Robert-Depot
Jump to: navigation, search
(modifying for rudimentary keyboard control)
(controlling from a Processing app)
Line 40: Line 40:
 
*Computer -> Arduino
 
*Computer -> Arduino
 
*Arduino -> Computer
 
*Arduino -> Computer
 +
 +
=== Homework ===
 +
With your sensor, build a simple computer/microprocessor project.  Establish communication between the computer and processor, either controlling the device with commands from your computer program, or driving the computer program with information from the processor.  You may use Processing, and adapt one of the simple examples we have seen in class, or you can use any other program you are comfortable with (Flash, MaxMSP, PD), so long as you can demonstrate it to us in class next week.  We will take the first part of class to look at your ideas for these projects.  <!-- Also, please register on the wiki and post a short description of your project. -->
  
 
== Extra ==
 
== Extra ==
  
 
Connecting to various external devices and components: http://www.arduino.cc/playground/Main/ComponentLib
 
Connecting to various external devices and components: http://www.arduino.cc/playground/Main/ComponentLib

Revision as of 20:55, 20 April 2009

Interfacing

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, 28*(val-'0'));
 }
}
  • Connect up the TIP120 driver circuit and motor from last week. Voila! You have a simple motor speed control, through the computer.

controlling from a Processing app

See the commented out Processing code at the end of Dimmer example.

  • Computer -> Arduino
  • Arduino -> Computer

Homework

With your sensor, build a simple computer/microprocessor project. Establish communication between the computer and processor, either controlling the device with commands from your computer program, or driving the computer program with information from the processor. You may use Processing, and adapt one of the simple examples we have seen in class, or you can use any other program you are comfortable with (Flash, MaxMSP, PD), so long as you can demonstrate it to us in class next week. We will take the first part of class to look at your ideas for these projects.

Extra

Connecting to various external devices and components: http://www.arduino.cc/playground/Main/ComponentLib