This “Serial Duplex” lab makes use of multiple sensors.  In my case, I used a potentiometer and a photocell for the analog inputs and a standard switch for the digital one.

Pcomp week 7 lab wiring

After following the instructions and getting the white circle to move horizontally and vertically based on the sensor values, I changed my Processing code to create an ellipse in openGL that rotates on the Z axis.  I mapped the values from the photocell (“g = map(sensors[0], 50,520,1,255);”) to both the Green value of the ellipse color and the Z value of the “translate” code (for example: “translate(width/2, height/2, g);”).  I mapped the values of the potentiometer (“b = map(sensors[1], 0,1023,1,255);”) to both the Blue value of the ellipse color and the Z value of the actual ellipse (“ellipse(0, 0, 100, b);”).  I didn’t really want to use the switch, so I just set it to the Red value of the ellipse color.  The “theta” value for the Z rotation increased by 0.02.  Here’s the video demo, shot by Matt Richard:

Pcomp Week 7 Lab: Multiple Serial Output from N Z on Vimeo.

« »