My project is a controller lamp (did ??from the control relay 5v) and used two other relays.
one relay plays the role of a (motor electricity) and the other relay plays the role of (the state electricity).
Relay 5 V: Connect to pin 5 arduino and connect to lamp that connects to electricity
relay 220v (State): Connect to pin 2 (interrupt 0) and connect cable to electricity
relay 220v (motor): connect pin 3 (interrupt 1) and connect cable to electricity
and a sensor measuring the lamp current
I'm there when (the state electricity) the fluorescent lamp when I remove the cable of electricity (turn off the lamp) and at the same time must measure the current and if the current> 0.2 light the lamp nor Turns off the lamp from relay pin 3
if anyone can help with, thank you.
code
#define relayx 2
#define relay2 5
#define relayy 3
volatile int x=LOW;
void setup()
{
Serial.begin(9600);
pinMode(relay2, OUTPUT);
attachInterrupt(0,ETAT,FALLING);
attachInterrupt(1,relaymoteur,RISING);
}
void loop()
{
measure current ( x)
}
void ETAT(){
digitalWrite(relay2,HIGH);
}
void relaymoteur(){
if (x>0.2)
{
digitalWrite(relay2, HIGH);
while(1){}
}
else
{
digitalWrite(relay2, LOW);
while(1){}
}
}