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 ,

Bose Wave Radio II Arduino Remote Clone

After recently reading the Clone a Remote with Arduino instructable by randofo, I was inspired to try to clone the remote of my Bose Wave Radio II. While this radio is outstanding from an acoustic perspective, the fact that it’s only means of control are by remote (only one remote is included) makes this single point of failure design far from ideal.

My goal was to essentially create a “backup” version of the included remote with only the basic functions necessary to operate the radio in the event that something should happen to the remote itself (lost, broken, dead battery, etc.).

I started with the Raw IR Decoder sketch on randofo’s ‘able, loading it onto my Duemilanove. Then I hooked up the IR transmitter and pushbutton to my Uno. From there it was mostly trial and error to find the minor differences between the actual remote’s timing and my clone’s timing. Once I had the numbers, I just transposed them all into randofo’s framework for sending IR commands.

This sketch is just the barebones commands, implement control as you wish (build yourself a second remote with a button for each function, send serial commands to the arduino, etc.). Commands are easily accessed, simple function calls.

Command List
Volume + –> volumeUp()
Volume – –> volumeDown()
On/Off –> power()
FM –> fm()
AUX –> aux()
Preset # –> preset#()
EX: Preset 1 –> preset1()
Tune Up (>) –> tuneUp()
Tune Down ( tuneDown()
Mute –> mute()

See instructables for the file download. Also, download the instructable as a PDF here.

Basic IR Motion Alarm with Arduino

Just a little side project I worked on to create a better version of the basic radioshack motion alarm. Arduino based (hackduino specifically), expandable, and a good project to start playing with Arduino and electronics.

Motion Alarm Diagram

And here’s the code (it’ll look better once you paste it into the Arduino IDE):

///////////////////////////////////////////////////////////////////////////////
///////////////////////////// PIR Motion Alarms ///////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////// by loganemakf /////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

// VARIABLES

int ledPin = 12;
int pirPin = 3;
int alarmPin = 8;
long counter = 0;

// SETUP
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
pinMode(alarmPin, OUTPUT);
digitalWrite(pirPin, LOW);

// warmup time
digitalWrite(ledPin, HIGH);
for (int i = 0; i = 180000){ // if the counter reaches 180 seconds
digitalWrite(alarmPin, LOW); // turn the alarm off
while(digitalRead(pirPin) == HIGH){ // while the motion continues
digitalWrite(ledPin, HIGH); // turn on the led until motion stops
}
digitalWrite(ledPin, LOW); // then turn the led off
counter = 0; // set the counter back to 0
}
else{ // otherwise (counter is less than),
if(digitalRead(pirPin) == LOW){ // check to see if there is motion
delay(2000); // and wait 2 seconds to ensure none
if(digitalRead(pirPin) == LOW){ // If there is still no motion
counter = 0; // reset counter
delay(40000); // and leave alarm on for 40 seconds
digitalWrite(alarmPin, LOW); // then turn the alarm off
}
else{ // and if there happens to be motion
goto label; // goto label (skip unneeded HIGH check)
}
}
}
}

}

Tagged , , ,