Hi, I'm facing some problem in interfacing my Arduino Mega with a 8 relay shield.
The shield specification can be found here http://cgi.ebay.it/Eight-8-Relay-Module-Board-for-8051-PIC-Project-12V-/130485564595?pt=LH_DefaultDomain_0&hash=item1e618bb4b3.
I've powered the shield with an external 12 V DC power supply (1000 mA) and connect the GND of the power supply with the Arduino Mega GND pin (I've read it in some posts).
I've also set an Arduino DIGITAL pin as OUTPUT (pin 50 on the sketch) and put it to HIGH but the realy remain open and didn't change its state.....?!?!??
Can someone give me some advice on that?
Thanks in advanced
Here is the sketch I used...
// look for IR codes and print them as they are received
//You also need to wire the 12 volt supply ground to the Arduino ground, otherwise the transistor will never turn on.
#include <WProgram.h>
#include <NECIRrcv.h>
#define IRPIN 36 // pin that IR detector is connected to
NECIRrcv ir(IRPIN);
int PinRelay1 = 50;
void setup()
{
Serial.begin(9600) ;
Serial.println("NEC IR code reception");
ir.begin() ;
pinMode (PinRelay1, OUTPUT);
//digitalWrite (PinRelay1,LOW);
}
void loop()
{
unsigned long ircode ;
while (ir.available()) {
ircode = ir.read() ;
//Serial.println (ircode);
switch (ircode)
{
case 3910598400:
Serial.println ("Hai premuto il tasto 0");
Serial.println ("attendi, sto accendendo il rele' 1");
digitalWrite (PinRelay1, HIGH);
break;
case 4077715200:
Serial.println ("Hai premuto il tasto 1");
Serial.println ("attendi, sto spegnendo il rele' 1");
digitalWrite (PinRelay1, LOW);
break;
case 3877175040:
Serial.println ("Hai premuto il tasto 2");
break;
case 2707357440:
Serial.println ("Hai premuto il tasto 3");
break;
case 4144561920:
Serial.println ("Hai premuto il tasto 4");
break;
case 3810328320:
Serial.println ("Hai premuto il tasto 5");
break;
case 2774204160:
Serial.println ("Hai premuto il tasto 6");
break;
case 3175284480:
Serial.println ("Hai premuto il tasto 7");
break;
case 2907897600:
Serial.println ("Hai premuto il tasto 8");
break;
case 3041591040:
Serial.println ("Hai premuto il tasto 9");
break;
case 3860463360:
Serial.println ("Hai premuto il tasto 100+");
break;
case 4061003520:
Serial.println ("Hai premuto il tasto Indietro");
break;
case 3125149440:
Serial.println ("Hai premuto il tasto Spegnimento Totale");
break;
case 3108437760:
Serial.println ("Hai premuto il tasto Mode");
break;
case 3091726080:
Serial.println ("Hai premuto il tasto Mute");
break;
case 3141861120:
Serial.println ("Hai premuto il tasto Pagina Precedente");
break;
case 3208707840:
Serial.println ("Hai premuto il tasto Pagina Successiva");
break;
case 3158572800:
Serial.println ("Hai premuto il tasto Play/Pause");
break;
case 4161273600:
Serial.println ("Hai premuto il tasto Volume -");
break;
case 3927310080:
Serial.println ("Hai premuto il tasto Volume +");
break;
case 4127850240:
Serial.println ("Hai premuto il tasto Equalizzatore");
break;
}
}
}
P.S: in the sketch I use a remote control for switch the realy to OPEN or CLOSED.