Go Down

Topic: Diy remote prank please help! (Read 587 times) previous topic - next topic

conmor

Oct 23, 2012, 05:02 am Last Edit: Oct 23, 2012, 06:22 am by conmor Reason: 1
Hi there, I am stumped on this:
I want to get more than one pin to do the exact same thing as pin 3 in this example, as I want to hookup more IR leds to make the remote signal stronger. If this doesent make sense, I am trying to use more than one pin to add more IR leds to this remote, thus making it have a stronger signal. I initally tried to do this by assigning more than one pin to an int value (such as int led = 3, 4, 5; ) but it didnt work as planned. Could someone please help me? Thanks so much! Here is the code:
Code: [Select]
#include <AppleRemoteSender.h>

int irLed  = 3;





long randomtime;
long randomaction;

byte remoteID = 0x05;
AppleRemoteSender ars = AppleRemoteSender(irLed, remoteID);

void setup()   {            
 randomSeed(analogRead(0)); //make it more random :o
  //wait five minutes so we have time to hide the arduino.
}

void loop() //let's start annoying! :D                    
{
randomaction = random(6); //get a random number (0, 1, 2, 3, 4 or 5) to randomize the action

if (randomaction = 0) //if the random number is 0
{
   ars.left(); //we've got to go back... to the future! (send the left button command)
   ars.left();
   ars.left();
}
else if (randomaction = 1) //if it's 1
{
  ars.right(); //we've got to go forward... to the past! (send the right button command)
  ars.right();
  ars.right();
}
else if (randomaction = 2) //if it's 2
{
  ars.menu(); //main scr...menu turn on!
  ars.menu();
  ars.menu();
}
else if (randomaction = 3) //if it's 3
{
  ars.play(); //play!
  ars.play();
  ars.play();
}
else if (randomaction = 4) //if it's 4
{
  ars.up(); //louder... louder... LOUDER...
  ars.up();
  ars.up();
}
else if (randomaction = 5) //if it's 5
{
  ars.down(); //volume down
  ars.down();
  ars.down();
}
delay(500); //wait half a second
}

conmor

If you have any ideas, please post them!! I greatly appreciate it! Thanks.

MichaelMeissner

Ummm, I think you need to go back and read your C/C++ reference manuals.  You are confusing '=' (assignment) with '==' (equality).

For example:
Code: [Select]

if (randomaction = 0) //if the random number is 0
    {
        // ...
    }
else if (randomaction = 1) //if it's 1
    {
        // ....
    }


This will always do the second test, because you have first set randomaction to 0, and then tested it for it being non-zero, and it isn't, so you go onto the else if.  Then you assign 1 to randomaction, and test whether that is true, and it is.

I also tend to think that using more LEDs all together will probably just give you a marginally more powerful light.  If you want more distance, I would think you would want to use an opto-isolator to drive a more powerful light that uses a higher power source than the Arduino supplies.

If you want multiple LEDs doing the exact same thing, Have the pin drive a transistor and just connect all of the leds in parallel with the transistor.

This circuit is vaguely the idea but obviously the specifics would be different, your voltage, number of LEDs in series and parallel, etc.

Go Up