Category Archives: Uncategorized

Wave Radio Control with Processing

I threw together a program to control an arduino with IR LED with a computer. You can download the zip file with the control program (open the folder of your operating system) and, of course, the arduino code. Below is the processing sketch (and linked file):


// Need G4P library
import guicomponents.*;
import processing.serial.*;
Serial port;
int ardPort = 1; //Input the port of the arduino

void setup(){
size(225, 352);
createGUI();
customGUI();
// Place your setup code here
port = new Serial(this, Serial.list()[ardPort], 9600);

}

void draw(){
background(200,255,200);

}

// Use this method to add additional statements
// to customise the GUI controls
void customGUI(){

}

void portUp(){
ardPort += 1;
}

void portDown(){
ardPort -= 1;
}

And the linked file (named ‘gui’):

/* =========================================================
* ==== WARNING ===
* =========================================================
* The code in this tab has been generated from the GUI form
* designer and care should be taken when editing this file.
* Only add/edit code inside the event handlers i.e. only
* use lines between the matching comment tags. e.g.

void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
} //_CODE_:button1:12356:

* Do not rename this tab!
* =========================================================
*/

void btnPwr_Click1(GButton button) { //_CODE_:btnPwr:389177:
port.write(1);
} //_CODE_:btnPwr:389177:

void btnFM_Click1(GButton button) { //_CODE_:btnFM:928840:
port.write(2);
} //_CODE_:btnFM:928840:

void btnAUX_Click1(GButton button) { //_CODE_:btnAUX:929041:
port.write(3);
} //_CODE_:btnAUX:929041:

void btnMute_Click1(GButton button) { //_CODE_:btnMute:428424:
port.write(4);
} //_CODE_:btnMute:428424:

void btnVup_Click1(GButton button) { //_CODE_:btnVup:718445:
port.write(5);
} //_CODE_:btnVup:718445:

void btnVdown_Click1(GButton button) { //_CODE_:btnVdown:927705:
port.write(6);
} //_CODE_:btnVdown:927705:

void btnP1_Click1(GButton button) { //_CODE_:btnP1:966109:
port.write(7);
} //_CODE_:btnP1:966109:

void btnP2_Click1(GButton button) { //_CODE_:btnP2:546867:
port.write(8);
} //_CODE_:btnP2:546867:

void btnP3_Click1(GButton button) { //_CODE_:btnP3:501504:
port.write(9);
} //_CODE_:btnP3:501504:

void btnP4_Click1(GButton button) { //_CODE_:btnP4:684524:
port.write(10);
} //_CODE_:btnP4:684524:

void btnP5_Click1(GButton button) { //_CODE_:btnP5:783322:
port.write(11);
} //_CODE_:btnP5:783322:

void btnP6_Click1(GButton button) { //_CODE_:btnP6:637495:
port.write(12);
} //_CODE_:btnP6:637495:

void btnTd_Click1(GButton button) { //_CODE_:btnTd:464101:
port.write(13);
} //_CODE_:btnTd:464101:

void btnTu_Click1(GButton button) { //_CODE_:btnTu:973849:
port.write(14);
} //_CODE_:btnTu:973849:

void portdown_Click1(GButton button) { //_CODE_:btnprtdown:421879:
portUp();
} //_CODE_:btnprtdown:421879:

void portup_Click1(GButton button) { //_CODE_:btnportup:724886:
portDown();
} //_CODE_:btnportup:724886:

// Create all the GUI controls.
// autogenerated do not edit
void createGUI(){
G4P.setColorScheme(this, GCScheme.BLUE_SCHEME);
G4P.messagesEnabled(false);
btnPwr = new GButton(this, "On/Off", 48, 16, 129, 29);
btnPwr.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnPwr.addEventHandler(this, "btnPwr_Click1");
btnFM = new GButton(this, "FM", 96, 72, 32, 28);
btnFM.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnFM.addEventHandler(this, "btnFM_Click1");
btnAUX = new GButton(this, "AUX", 160, 72, 32, 28);
btnAUX.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnAUX.addEventHandler(this, "btnAUX_Click1");
btnMute = new GButton(this, "Mute", 24, 256, 50, 25);
btnMute.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnMute.addEventHandler(this, "btnMute_Click1");
btnVup = new GButton(this, "Up", 16, 144, 50, 25);
btnVup.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnVup.addEventHandler(this, "btnVup_Click1");
btnVdown = new GButton(this, "Down", 16, 184, 50, 25);
btnVdown.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnVdown.addEventHandler(this, "btnVdown_Click1");
btnP1 = new GButton(this, " 1", 88, 144, 25, 25);
btnP1.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP1.addEventHandler(this, "btnP1_Click1");
btnP2 = new GButton(this, "2", 128, 144, 25, 25);
btnP2.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP2.addEventHandler(this, "btnP2_Click1");
btnP3 = new GButton(this, "3", 168, 144, 25, 25);
btnP3.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP3.addEventHandler(this, "btnP3_Click1");
btnP4 = new GButton(this, "4", 88, 184, 25, 25);
btnP4.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP4.addEventHandler(this, "btnP4_Click1");
btnP5 = new GButton(this, "5", 128, 184, 25, 25);
btnP5.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP5.addEventHandler(this, "btnP5_Click1");
btnP6 = new GButton(this, "6", 168, 184, 25, 25);
btnP6.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnP6.addEventHandler(this, "btnP6_Click1");
btnTd = new GButton(this, "", 160, 256, 25, 25);
btnTu.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnTu.addEventHandler(this, "btnTu_Click1");
Mode = new GLabel(this, "Mode:", 24, 72, 40, 20);
Presets = new GLabel(this, "Presets:", 120, 120, 48, 20);
Vol = new GLabel(this, "Vol.", 24, 120, 32, 20);
Tune = new GLabel(this, "Tune", 128, 232, 40, 20);
Wave_Radio_II = new GLabel(this, "Wave Radio II", 72, 328, 80, 20);
prtlabl = new GLabel(this, "Port Selector:", 16, 296, 80, 20);
btnprtdown = new GButton(this, "", 184, 296, 25, 25);
btnportup.setTextAlign(GAlign.CENTER | GAlign.MIDDLE);
btnportup.addEventHandler(this, "portup_Click1");
}

// Variable declarations
// autogenerated do not edit
GButton btnPwr;
GButton btnFM;
GButton btnAUX;
GButton btnMute;
GButton btnVup;
GButton btnVdown;
GButton btnP1;
GButton btnP2;
GButton btnP3;
GButton btnP4;
GButton btnP5;
GButton btnP6;
GButton btnTd;
GButton btnTu;
GLabel Mode;
GLabel Presets;
GLabel Vol;
GLabel Tune;
GLabel Wave_Radio_II;
GLabel prtlabl;
GButton btnprtdown;
GButton btnportup;

Tagged ,