Difference between revisions of "Week 4 Lab"

From Robert-Depot
Jump to: navigation, search
(Interfacing)
(Interfacing)
Line 2: Line 2:
 
*Download and install processing http://processing.org/download
 
*Download and install processing http://processing.org/download
  
*Serial Interface
+
== Serial Interface, for debugging ==
 
Sketchbook->Examples->Communication->ASCIITable
 
Sketchbook->Examples->Communication->ASCIITable
 +
Serial.print()
 +
Serial.println()
  
 +
== Dimmer ==
 
Examples->Communication->Dimmer
 
Examples->Communication->Dimmer
 
 
Controlling a physical LED with the computer.
 
Controlling a physical LED with the computer.
 
+
<code>
 
+
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'));
 +
  }
 +
}
 +
</code>
 
*Processing, MaxMSP, and many more.
 
*Processing, MaxMSP, and many more.
 
*Computer -> Arduino
 
*Computer -> Arduino

Revision as of 20:29, 20 April 2009

Interfacing

Serial Interface, for debugging

Sketchbook->Examples->Communication->ASCIITable

Serial.print()
Serial.println()

Dimmer

Examples->Communication->Dimmer Controlling a physical LED with the computer. 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'));
 }

}

  • Processing, MaxMSP, and many more.
  • Computer -> Arduino
  • Arduino -> Computer

Extra

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