Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /pumpkinarduino.pde

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Eye-Popping Pumpkin Processing/Arduino
//-----------------------Start Arduino Code------------------------------
int message = 0; // This will hold one byte of the serial message
int eyesPin = 9; // What pin are the eyes connected to?
int eyes_val = LOW; // eyes_val will be HIGH or LOW
void setup()
Serial.begin(9600); //set serial to 9600 baud rate
void loop()
if (Serial.available() > 0)
{ // Check if there is a new message
message =; // Put the serial input into the message
if (message == 'R')
{ // If a capitol R is received...
eyes_val = HIGH; // Set eyes_val to HIGH and eyes are out
if (message == 'r')
{ // If a lowercase r is received...
eyes_val = LOW; // Set eyes_val to LOW and eyes are in
digitalWrite(eyesPin, eyes_val); // Write digital value to eyes
//----------------------------end Arduino code--------------------------------
//----------------------------------start processing code------------------------------------
import oscP5.*; // Load OSC P5 library
import netP5.*; // Load net P5 library
import processing.serial.*; // Load serial library
Serial arduinoPort; // Set arduinoPort as serial connection
OscP5 oscP5; // Set oscP5 as OSC connection
float eyes_val;
//--- Function: setup
void setup()
oscP5 = new OscP5(this,8000); // Start oscP5, listening for incoming messages at port 8000
arduinoPort = new Serial(this, Serial.list()[0], 9600); // Set arduinoPort to 9600 baud
//--- Function: oscEventThis runs whenever there is a new OSC message
void oscEvent(OscMessage theOscMessage) {
String addr = theOscMessage.addrPattern();
if(addr.equals("/1/push1")) {
eyes_val = theOscMessage.get(0).floatValue();
//--- Function: pneumatic eyes on/off
void draw()
if (eyes_val > 0.5) {
arduinoPort.write('R');//sends signal for eyes out
else {
arduinoPort.write('r');//sends signal for eyes in
//----------------------------------end processing code------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.