Changes

Jump to: navigation, search

Classes/2010/VIS147A

1,349 bytes added, 20:50, 2 March 2010
Week 9 - Interfacing with the computer, higher level sensors
* Homework 9:
* Lab 9: [[Classes/2010/VIS147A/Lab9 | serial communication]]
 
 
==== Problems with lab 9 ===
 
(Christa & Samantha were working on the rudimentary keyboard control for processing and this is what they came up with. Can anyone fix the code? The problem seems to lie within the port.write() function. The code given in lab doesn't work because it is actually code for Arduino, not Processing)
 
/* Processing code for this example */
// Dimmer - sends bytes over a serial port
// by David A. Mellis
// This example code is in the public domain.
import processing.serial.*;
Serial port;
int value;
void setup() {
size(256, 150);
println("Available serial ports:");
println(Serial.list());
// Uses the first port in this list (number 0). Change this to
// select the port corresponding to your Arduino board. The last
// parameter (e.g. 9600) is the speed of the communication. It
// has to correspond to the value passed to Serial.begin() in your
// Arduino sketch.
port = new Serial(this, Serial.list()[0], 9600);
// If you know the name of the port used by the Arduino board, you
// can specify it directly like this.
//port = new Serial(this, "COM1", 9600);
}
 
 
void draw(){
port.write(value);
}
 
void keyReleased() {
if (key >= '0' && key <= '9') {
value = key - '0';
// port.write(value*28);
println(key);
println(value);
 
}
 
}
=== Week 10 - Summary, discussion, wind-down. ===
25
edits

Navigation menu