Pages: [1]   Go Down
 Author Topic: [SOLVED] Roomba From PRONTO CODE to IR Emitter (IR LED + RAWCODE + ARDUINO)  (Read 393 times) 0 Members and 1 Guest are viewing this topic.
italy
Offline
Newbie
Karma: 0
Posts: 9
 « on: February 19, 2013, 03:36:55 am » Bigger Smaller Reset

Hi to all,
I'm trying to use arduino to control a roomba vaccum cleaning robot.
My project has a very simple IR Led and a 100 OHM resistor connected to the board.

I found this pronto code:
http://www.robotreviews.com/chat/viewtopic.php?t=8682#p64966

For clean:
0000 0069 0000 0008 0071 0027 0023 0071 0023 0071 0023 0071 0071 0027 0023 0071 0023 0071 0023 030B

I read all the documentation about Pronto code, and I was able to understand that

Frequency (hz) is: 39478
1 Cycle (ms) is: 0.025330563858351
First burst pair: 0
Second burst pairs: 8
0071 0027 means 0
0023 0071 means 1

So the string to send (3 times) is: 01110111

Well.....

The first thing I though is to use irlibrary... but how?  SendRaw(X,Y,Z) with X a vector of hex converter to decimal, Y ?? Z=8???
I made several trials but I could'nt figure it out..

I found a script at:
http://l8ter.com/arduino/index.php

That's generate this code

Code:
int pinIRLED = 13;                                      // assign the Infrared emitter/ diode to pin 13
void setup() {
pinMode(pinIRLED, OUTPUT);                            // set the pin as an output
}
// sets the pulse of the IR signal.
void pulseON(int pulseTime) {
unsigned long endPulse = micros() + pulseTime;        // create the microseconds to pulse for
while( micros() < endPulse) {
digitalWrite(pinIRLED, HIGH);                       // turn IR on
delayMicroseconds(13);                              // half the clock cycle for 38Khz (26.32×10-6s) - e.g. the 'on' part of our wave
digitalWrite(pinIRLED, LOW);                        // turn IR off
delayMicroseconds(13);                              // delay for the other half of the cycle to generate wave/ oscillation
}
}
void pulseOFF(unsigned long startDelay) {
unsigned long endDelay = micros() + startDelay;       // create the microseconds to delay for
while(micros() < endDelay);
}
void takePicture() {
for (int i=0; i < 2; i++) {

pulseOFF(2862);
pulseON(988);
pulseOFF(887);
pulseON(2862);
pulseOFF(887);
pulseON(2862);
pulseOFF(887);
pulseON(2862);
pulseOFF(2862);
pulseON(988);
pulseOFF(887);
pulseON(2862);
pulseOFF(887);
pulseON(2862);
pulseOFF(887);
pulseON(19733);
}                                                     // loop the signal twice.
}
void loop() {
takePicture();                                        // take the picture
delay(5000);                                          // delay in milliseconds which allows us to do timelapse photography - 1 second = 1000 milliseconds
}

It seems to be wrong (it start with pulse off..) and in fact it doesn't work.. I try to invert pulse on/off (the timing seems to be correct) but it still doesn't work also if I repeat it 3 times (not 2 as the script do )

I have no idea on how I can figure it out and make my project work.. Please help me.

NB I read all the documentation regarding pronto code from remote central and from other website, I manually decodify it, I try to be accurate in defining the right frequency and cycle...

NB2 I don't have the original remote, so I can't use irLibrary to decode the signals
 « Last Edit: February 23, 2013, 06:07:42 am by maniiu » Logged

italy
Offline
Newbie
Karma: 0
Posts: 9
 « Reply #1 on: February 19, 2013, 10:46:31 am » Bigger Smaller Reset

 Logged

italy
Offline
Newbie
Karma: 0
Posts: 9
 « Reply #2 on: February 23, 2013, 06:05:02 am » Bigger Smaller Reset

Finally I was able to make it works:

Code:

#include <IRremote.h>

IRsend irsend;

//unsigned int clean[] = {2650,1100,750,2900,750,2950,700,2950,2700,1100,700,2950,750,2900,750};
unsigned int manu2[32]= {2872,999,897,2872,897,2872,897,2872,2872,999,897,2872,897,2872,897};

void setup()
{
Serial.begin(9600);
}

void loop() {

for (int i = 0; i < 4; i++) {
//irsend.sendRaw(clean, 15, 38);
irsend.sendRaw(manu2, 15, 39);
Serial.println("Roomba GO~~~~~~~~~~~~~~~~~");
delay(40);

}
delay(5000);
}

Manu2 is the best rawcode, derivated directly from Pronto Code (specs found on remote central site).
I hope this will help other people looking for similar solutions

Ciao
 Logged

Offline
Newbie
Karma: 0
Posts: 4
 « Reply #3 on: March 17, 2013, 05:44:01 am » Bigger Smaller Reset

Here is a sketch I wrote to send different commands to the Roomba.

For example, enter "136" in the serial monitor, press enter, and the Roomba performs "clean". A list of codes to be sent is also included with the sketch.

https://gist.github.com/probonopd/5181021
 Logged

 Pages: [1]   Go Up