Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« on: July 02, 2012, 12:07:17 pm » |
Hi there, I used the ladyada's tutorial on IR to recieve the code of my TV remote, that worked out great, and here it is: 86, 88, 176, 88, 84, 90, 86, 88, 86, 88, 84, 90, 84, 94, 82, 88, 84, 174, 84, 90, 176, 88, 86, 2394, 86, 88, 176, 88, 86, 92, 88, 82, 92, 82, 86, 88, 86, 88, 92, 82, 92, 166, 92, 82, 182, 82, 86, 2398, 88, 82, 182, 82, 86, 88, 86, 88, 92, 82, 92, 86, 82, 84, 96, 82, 86, 172, 92, 82, 182, 86, 82, 0 Now I have an IR LED and I would like to transmit this sequence with it. Only problem is that Ladyada did not explain well (at least to me) how to do so, He only gave his personal example using his Apple remote. Should I copy and pase each and every number to the frame of "PulseIR" and "delay"? because it will take hours and I bet there is another way to copy and paste everything into a code or something. Please make it simple, THANKS!
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #1 on: July 02, 2012, 12:32:32 pm » |
I used the ladyada's tutorial on IR I'm not hunting for it. Post a link.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #2 on: July 02, 2012, 12:42:40 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Delray Beach, FL USA
Offline
Full Member
Karma: 0
Posts: 113
|
 |
« Reply #3 on: July 02, 2012, 12:58:47 pm » |
I'm working on a fanatical IR remote project. You might be able to dig up useful info and/or code out of my web pages at: http://home.comcast.net/~tomhorsley/hardware/arduino/aardremote.htmlI use the arduino as a low level device I talk to with bluetooth or over USB and have a host system (my linux box or android phone) send commands and get back IR info.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #4 on: July 02, 2012, 03:37:12 pm » |
Guys, are you suggesting that I will copy each and every number from the sequence in to the figure the website gave? That's just not right.
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 108
Posts: 6607
|
 |
« Reply #5 on: July 02, 2012, 05:45:55 pm » |
Put the values in an array as per int IRsignal[] = { // ON, OFF (in 10's of microseconds)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #6 on: July 03, 2012, 02:34:02 am » |
How does that help me?
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 108
Posts: 6607
|
 |
« Reply #7 on: July 03, 2012, 05:47:46 am » |
How does that help me?
for (int i=0; i< pulses, i++) { pulseIR(IRsignal[2*i] * 10'); delayMicroseconds(IRsignal[2*i+1] * 10); }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #8 on: July 03, 2012, 05:50:03 am » |
thanks. Where do i put this code, and where do I put the numbers from the remote?
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 108
Posts: 6607
|
 |
« Reply #9 on: July 03, 2012, 06:32:18 am » |
thanks. Where do i put this code, and where do I put the numbers from the remote?
You put the code in the place in your sketch where you want to send the signal. You put your numbers in the IRsignal array, like they show in the examples you referenced.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #10 on: July 03, 2012, 06:41:26 am » |
I need a complete code that pulses the IR LED according to my numbers. You gave me a segment of the code and told me to put it in what sketch? and let's say I put them in the array, like this: int IRsignal[] = { // ON, OFF (in 10's of microseconds) 86, 88, 176, 88, 84, 90, 86, 88, 86, 88, 84, 90, 84, 94, 82, 88, 84, 174, 84, 90, 176, 88, 86, 2394, 86, 88, 176, 88, 86, 92, 88, 82, 92, 82, 86, 88, 86, 88, 92, 82, 92, 166, 92, 82, 182, 82, 86, 2398, 88, 82, 182, 82, 86, 88, 86, 88, 92, 82, 92, 86, 82, 84, 96, 82, 86, 172, 92, 82, 182, 86, 82, 0}; Now it's in the array, how do I combine it with the pulsing code? I'm confused
|
|
|
|
|
Logged
|
|
|
|
|
Massachusetts, USA
Offline
Tesla Member
Karma: 108
Posts: 6607
|
 |
« Reply #11 on: July 03, 2012, 07:45:44 am » |
I need a complete code that pulses the IR LED according to my numbers. You gave me a segment of the code and told me to put it in what sketch?
OK, I'll write the full sketch for you, but you won't learn much that way. // This sketch will send out an arbitrary IR signal
int IRledPin = 13; // LED connected to digital pin 13
const int pulses = 37;
const int IRsignal[pulses*2] = { // ON, OFF (in 10's of microseconds) 86, 88, 176, 88, 84, 90, 86, 88, 86, 88, 84, 90, 84, 94, 82, 88, 84, 174, 84, 90, 176, 88, 86, 2394, 86, 88, 176, 88, 86, 92, 88, 82, 92, 82, 86, 88, 86, 88, 92, 82, 92, 166, 92, 82, 182, 82, 86, 2398, 88, 82, 182, 82, 86, 88, 86, 88, 92, 82, 92, 86, 82, 84, 96, 82, 86, 172, 92, 82, 182, 86, 82, 0};
// The setup() method runs once, when the sketch starts
void setup() { // initialize the IR digital pin as an output: pinMode(IRledPin, OUTPUT);
Serial.begin(9600); }
void loop() { Serial.println("Sending IR signal");
SendCode(pulses, IRsignal);
delay(60*1000); // wait one minute (60 seconds * 1000 milliseconds) }
// This procedure sends a 38KHz (26 microsecond cycle time) pulse to the IRledPin // for a certain # of microseconds. We'll use this whenever we need to send codes void pulseIR(long microsecs) { // we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) { // 38 kHz is about 13 microseconds high and 13 microseconds low digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen delayMicroseconds(10); // hang out for 10 microseconds digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether microsecs -= 26; }
sei(); // this turns them back on }
void SendCode(const int pulses, const int IRsigna[]) {
for (int i=0; i< pulses; i++) { pulseIR(IRsignal[2*i] * 10); delayMicroseconds(IRsignal[2*i+1] * 10); } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 58
|
 |
« Reply #12 on: July 03, 2012, 07:53:27 am » |
Wow thanks a lot! I think it's easier and more effective to learn out of an exciting code. Now, Instead of the 60 second delay I want to put a switch and every time I click the switch it will kick the code. What I need to do is just embed the "button" example instead of the 60*1000 line?
|
|
|
|
|
Logged
|
|
|
|
|
Dubai, UAE
Offline
Edison Member
Karma: 20
Posts: 1637
|
 |
« Reply #13 on: July 03, 2012, 08:09:23 am » |
OK, I'll write the full sketch for you, but you won't learn much that way. Slow day at work, or just wanted to get it over and done with ? Duane B
|
|
|
|
|
Logged
|
|
|
|
|
|