Work in progress… I will update this with more images/code/tutorial

TouchOSC file for the iPad:
remote lamp.touchosc

Fritzing file:
nexa remote control_v0.1

Code on Github:
https://github.com/rabbadab/arduino/tree/master/projects/Arduino_TouchOSC


//Credits to Jerome Dupraz & Retocama
#include
#include  // Tested in version IDE 0022 Arduino UNO

#include
byte myMac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte myIp[] = { 192, 168, 1, 12 };
int serverPort = 10000;
float dw3 = 0; // Variable to set value for Digital pin 2 to digitalWrite
float dw5 = 0;

Z_OSCServer server;

Z_OSCMessage *rcvMes;

void setup(){
 //Pins 4,10 are used for the Ethernet shield . Adding pins 8 and 9 for use made this code buggy.

 //Set pins as Outputs
 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);

 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 Serial.begin(19200);

 Ethernet.begin(myMac ,myIp);

 server.sockOpen(serverPort);

}

void loop(){

if(server.available()){

 rcvMes=server.getMessage();

logMessage();

 //Digital pins

 // First Lamp On/Off
 if ( !strcmp( rcvMes->getZ_OSCAddress() , "/1/toggle1" ))
 {

 dw3 = rcvMes->getFloat(0); //Get fith value from incoming /arduino/out
 dw3 = constrain(dw3, 0, 1); // limit the value to 0-1
 Serial.println(dw3);
// ON
 if ( dw3 == 1 ) {
 digitalWrite(3,HIGH); // set pwm value on PIN
 delay(100);
 digitalWrite(3,LOW);
 }
// OFF
 else {
 digitalWrite(2,HIGH);
 delay(100);
 digitalWrite(2,LOW);
 }
 }

 // First Lamp
 if ( !strcmp( rcvMes->getZ_OSCAddress() , "/1/toggle2" ))
 {

 dw5 = rcvMes->getFloat(0); //Get fith value from incoming /arduino/out
 dw5 = constrain(dw5, 0, 1); // limit the value to 0-1
 Serial.println("dw5");
 Serial.println(dw5);
//ON
 if ( dw5== 1 ) {
 digitalWrite(5,HIGH); // set pwm value on PIN
 delay(100);
 digitalWrite(5,LOW);
 }
// OFF
 else {
 digitalWrite(6,HIGH);
 delay(100);
 digitalWrite(6,LOW);
 }
 }

 }
 }

 //Log maker

void logMessage(){
 uint16_t i;
 byte *ip=rcvMes->getIpAddress();

 long int intValue;
 float floatValue;
 char *stringValue;

 Serial.print(ip[0],DEC);
 Serial.print(".");
 Serial.print(ip[1],DEC);
 Serial.print(".");
 Serial.print(ip[2],DEC);
 Serial.print(".");
 Serial.print(ip[3],DEC);
 Serial.print(":");

 Serial.print(rcvMes->getPortNumber());
 Serial.print(" ");
 Serial.print(rcvMes->getZ_OSCAddress());
 Serial.print(" ");
 Serial.print(rcvMes->getTypeTags());
 Serial.print("--");

 for(i=0 ; igetArgsNum(); i++){

 switch( rcvMes->getTypeTag(i) ){

 case 'i':
 intValue = rcvMes->getInteger32(i);

 Serial.print(intValue);
 Serial.print(" ");
 break;

 case 'f':
 floatValue = rcvMes->getFloat(i);

 Serial.print(floatValue);
 Serial.print(" ");
 break;

 case 's':
 stringValue = rcvMes->getString(i);

 Serial.print(stringValue);
 Serial.print(" ");
 break;

 }

 }
 Serial.println("");
}

Components:
Arduino
LiPower shield
Li 3,7V Battery
Red LED

Code made by elCalvoMike:
Download here:

https://github.com/rabbadab/arduino/tree/master/projects/heart

//Heartbeat LED
//elCalvoMike 12-6-2008
#define LED  13 //analog pin location for ArduinoMini - change for other boards
int i = 0;
int pmw = 255;  //set PWM max - this can differ for other board pins
int rate = 25;  //this is the beats per minute (60000 ms)
               //because there are two beats to simulate the 'lub-dub' of the heart,
               // a 60 beat heart rate is only a value of 30 in the rate variable
               //the delay is the key to this programs realism - divide the rate into a minute, then weight it and divide by the pmw
               //you can modify the weight by changing the fractions (i.e .1, .2, .6) but to keep the timing correct, they should total 1
               //.1+.2+.1+.6 = 1

void setup() {
 pinMode(LED, OUTPUT);
}

void loop(){
 for(i = 0; i < pmw; i++) {    analogWrite(LED,i);    delay(((60000/rate)*.1)/pmw);  }  for (i = pmw; i > 0; i--){
   analogWrite(LED,i);
   delay(((60000/rate)*.2)/pmw);
 }

   for(i = 0; i < pmw; i++) {    analogWrite(LED,i);    delay(((60000/rate)*.1)/pmw);  }  for (i = pmw; i > 0; i--){
   analogWrite(LED,i);
   delay(((60000/rate)*.6)/pmw);
 }

}

 Used components:
NEXA remote control
Otoisolator 4- channel from Sparkfun
330 ohm resistors

Code in github: https://github.com/rabbadab/arduino/tree/master/projects/onoff_serial
Code:


int remoteOneON = 2; //pin for 1 ON
int remoteOneOFF = 3; //pin for 1 OFF
int remoteTwoON = 4; //pin for 2 ON
int remoteTwoOFF = 5; //pin for 2 OFF
int remoteOneInd = 13; //pin for 1 LED
int remoteTwoInd = 12; //pin for 2 LED
int incomingByte = 0; //variable to hold incoming Serial data
// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pins as outputs:
pinMode(remoteOneON, OUTPUT);
pinMode(remoteOneOFF, OUTPUT);
pinMode(remoteTwoON, OUTPUT);
pinMode(remoteTwoOFF, OUTPUT);
pinMode(remoteOneInd, OUTPUT);
pinMode(remoteTwoInd, OUTPUT);
Serial.begin(9600); //initialize serial comm at 9600 baud
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
if (Serial.available() > 0) { //if Serial data is available
incomingByte = Serial.read(); //store the data in incoming byte
if(incomingByte == 'A'){ //A
digitalWrite(remoteOneInd, HIGH);
digitalWrite(remoteOneON, HIGH);
Serial.println("RemoteOneON High");
delay(100);
digitalWrite(remoteOneON, LOW);
Serial.println("RemoteOneON Low");

}
else if(incomingByte == 'B'){ //B
digitalWrite(remoteOneInd, LOW);
digitalWrite(remoteOneOFF, HIGH);
Serial.println("RemoteOneOFF High");
delay(100);
digitalWrite(remoteOneOFF, LOW);
Serial.println("RemoteOneOFF Low");
}

else if(incomingByte == 'C'){ //C
digitalWrite(remoteTwoInd, HIGH);
digitalWrite(remoteTwoON, HIGH);
Serial.println("RemoteTwoON High");
delay(100);
digitalWrite(remoteTwoON, LOW);
Serial.println("RemoteTwoOFF Low");
}

else if(incomingByte == 'D'){ //D
digitalWrite(remoteTwoInd, LOW);
digitalWrite(remoteTwoOFF, HIGH);
Serial.println("RemoteTwoOFF High");
delay(100);
digitalWrite(remoteTwoOFF, LOW);
Serial.println("RemoteTwoOFF Low");
}
}
}

So I got the Microphone and optoisolator from sparkfun so now I can start my project of making a clapper that will turn on and off my lights at home.
The plan is to detect claps and then use the optoisolator to close a circuit on a remote that controls remote switches (NEXA).
I got some help from Manoj Kunthu on youtube with the start of the code.
http://www.youtube.com/watch?v=mgQLSAtS-zQ

This is the first wiring:

Code after the break.

Read Full Article →

I bought the pan tilt bracket from sparkfun.
I assembled it quickly yesterday and used the code that sparkfun had in there comments for using the joystick shield and the pan & tilt.

I’ll upload a video soon on how it worked…

Wiring:

Code: pan_tilt_joystick.zip

Code works in Arduino 1.0:


#include "Servo.h"
// Store the Arduino pin associated with each input
const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;
Servo pan;
Servo tilt;
long currentX=0;
long currentY=0;
void setup() {
 Serial.begin(9600);
//out pins
 pan.attach(8);
 tilt.attach(9);
}
void loop() {
 currentX = map((long)analogRead(PIN_ANALOG_X), 0, 1023, 0, 180);
 currentY = map((long)analogRead(PIN_ANALOG_Y), 0, 1023, 0, 180);
 Serial.print("X: ");
 Serial.print(currentX);
 Serial.print(", ");
 Serial.print("Y: ");
 Serial.print(currentY);
 Serial.println();
 pan.write(currentX);
 tilt.write(currentY);
}