// Analog Out Erica Calogero // Created 21 February 2006 //Code for Processing import processing.serial.*; byte serialout = 0; float T = 0.0; float myfloat = 0.0; Serial port; void setup() { size(600, 600); background(0); port = new Serial(this, "COM4", 9600); } void draw() { myfloat = float(mouseX); T = (myfloat/width)*126; serialout = byte(T); port.write(serialout); //this is an optional debug println(serialout); } ///////////////////////////////////////////////////////////////////////////// /* Analog Out From Serial Port Erica calogero Code for Arduino Created: 21st February 2006 */ int ledOut = 9; byte val = 0; int serByte = -1; void setup() { pinMode(ledOut, OUTPUT); beginSerial(9600); } void loop() { serByte = serialRead(); if (serByte != -1) { val = serByte; } analogWrite(ledOut,val*2); }