March 31, 2010 9:07 AM
Using a GUI to Control Processing Output with ControlIP5, Firmata via Serial
by Anna Kaziunas Francebr> br> br>
I created this simple interface to control turning on and off an LED that is attached to a microcontroller via the serial port on my Mac. I wanted to see if I could get the ControlIP5 (used to create the GUI), Firmata and serial libraries working together before I tried using more complex hardware. I intend to experiment with driving multiple servos and possibly tinkering with bluetooth using the NXT library as an "cheap" way (it's "cheap" because I already own the Mindstorms hardware) to play around with bluetooth without buying additional bluetooth modules.
The interface is simple - the Turn On button turns the light on and the Turn Off button turns it off.


/*-------------------------------------------------------------------
* Fab Academy -- Module 09: Interface Programming
*--------------------------------------------------------------------
* Assignment: Write a user interface for an input &/or output
* device.
*--------------------------------------------------------------------
* Purpose: This program is a test to get the controlIP5, Firmata,
* and serial libraries working together through the serial port.
* This program uses a simple button GUI interface to turn on / of an
* LED.
*--------------------------------------------------------------------
* Anna Kaziunas France - 30 March 2010
* Combined / Modified example code from:
* controlIP5 buttons example (included the library download)
*------------------------------------------------------------------*/
import processing.serial.*;
import cc.arduino.*;
import controlP5.*;
ControlP5 controlP5;
// we have to use controlP5.Button here since there
// would be a conflict if we only use Button to declare button b.
controlP5.Button b;
Arduino arduino;
// Variables
int ledPin = 11;
int buttonValue = 0;
int myColor = color(0);
void setup() {
arduino = new Arduino(this, Arduino.list()[2], 57600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
size(640,480);
smooth();
frameRate(30);
controlP5 = new ControlP5(this);
controlP5.addButton("Turn_On",255,200,80,100,70);
controlP5.addButton("Turn_Off",0,200,160,100,70);
println(Arduino.list());
}
void draw()
{
background(myColor);
fill(buttonValue);
rect(20,20,width-40,height-40);
}
public void controlEvent(ControlEvent theEvent) {
println(theEvent.controller().name());
}
// function buttonA will receive changes from
// controller with name Turn_On
public void Turn_On(int theValue) {
println("a button event from Turn_On: "+theValue);
myColor = theValue;
arduino.digitalWrite(ledPin, Arduino.HIGH);
}
// function buttonB will receive changes from
// controller with name Turn_Off
public void Turn_Off(int theValue) {
println("a button event from Turn_Off: "+theValue);
myColor = theValue;
arduino.digitalWrite(ledPin, Arduino.LOW);
}
Puppet Master Final Project Page Updated
Shopbot Project - Modular Shelving
Diploma Completion Checklist Update - 08.14.2010
Unsuccessful Modela Troubleshooting - Partially Successful Switch to Roland Vinyl Cutter
Very Basic Beginner Assembly Tutorial III: How to Use Avrdude
Very Basic Beginner Assembly Tutorial II: How to Use Gavrasm to compile an .asm flie
Very Basic Assembly Tutorial I: Where to Get Gavrasm for the Mac OS
Complete and Working --> Modified Hello Echo + Button + FTDI v.2
Modified Hello Echo + Button + FTDI v.2 ---> In Progress
Modified Hello Echo + Button + FTDI v.1
Mantis Hardware / Software Trial Run
First 3D Scans - Modela Scan of Laughing Die and Shell
Interlocking Rings - 3D Printing
MakerBot Cupcake CNC- Assembling the Plastruder mk4 Spindle
Capacitive Sensing - PuppetMaster v.1-v.2
[Revised] Fab Academy Final Project Proposal: PuppetMaster
FabISB Round 2: Stuffing and Programming the Board
Making Programming, Connector and Serial Cables
Final Project Licencing and Distribution
Internet 0 / Zero - Milling, Stuffing & Setting Up the Boards
Spindle Assembly - Mantis Milling Machine
PuppetMaster Final Project Page
Encoded Building Materials with Computer Numerical Control Assembly
Final Project Plan: PuppetMaster Universal Remote
Final project: pinball machine themed on an unfinished opera by Dylan Thomas and Stravinsky
Electronics design and production
The Fabian: an Arduino-compatible, student-friendly board for Fab Labs
Super simple bootstrap 3-axis controller
Breadboard-friendly Attiny45 board
Using a GUI to Control Processing Output with ControlIP5, Firmata via Serial
My favorite python/GTK reference
Fab ISB - Round 1: Milling Out The Board
Completed TARDIS Cast | Working Light