Good Day Everyone we built a school project using arduino uno and 5v 8 channel relay with 220v AC on it . we created a 3 way switch using switch and relay and we're having trouble indicating if the switch is on/off on our mobile application can anyone please help us how to know how we can show in our application that the switch is already open .
Hard to help when you don't show your code. Use the code tag!
Please explain share your code and what is you facing the problem ?.
Without more information I would guess you're using one of the Sainsmart Relay Modules. Along with whatever data is being passed back and forth you could add the state of the switch. Whenever you update the relay's position update this state variable and add a getter function.
By 3 way switch, do you mean a setup where there are 2 switches controlling the load? If that is the case, then you will need to look at the load to see if it is on. At 220V, that needs to be done with care.
Get an opto that is rated for the voltage and put it in parallel with the load.
Or, if you are using only one relay to send power to the load, you should know when that is on from your code.
how to connect Internet shield with arduino
please help
Hello.
How can i run this relays (1+2 and 3+4) at same time?
int relayPin1 = 5; // IN1 connected to digital pin 5
int relayPin2 = 6; // IN2 connected to digital pin 6
int relayPin3 = 7; // IN3 connected to digital pin 7
int relayPin4 = 8; // IN4 connected to digital pin 8
void setup()
{
pinMode(relayPin1, OUTPUT); // sets the digital pin as output
pinMode(relayPin2, OUTPUT); // sets the digital pin as output
digitalWrite(relayPin1, HIGH); // Prevents relays from starting up engaged
digitalWrite(relayPin2, HIGH); // Prevents relays from starting up engaged
}
void loop()
{
digitalWrite(relayPin1, LOW);
delay(2500);
digitalWrite(relayPin1, HIGH);
delay(2500);
digitalWrite(relayPin2, LOW);
delay(2500);
digitalWrite(relayPin2, HIGH);
delay(2500);
}
void setup ()
{
pinMode(relayPin3, OUTPUT); // sets the digital pin as output
pinMode(relayPin4, OUTPUT); // sets the digital pin as output
digitalWrite(relayPin3, HIGH); // Prevents relays from starting up engaged
digitalWrite(relayPin4, HIGH); // Prevents relays from starting up engaged
}
void loop ()
{
digitalWrite(relayPin3, LOW);
delay(500);
digitalWrite(relayPin3, HIGH);
delay(500);
digitalWrite(relayPin4, LOW);
delay(500);
digitalWrite(relayPin4, HIGH);
delay(500);
}
int relayPin1.pdf (183 KB)
mistergreen:
Use the code tag!
kukainc:
Hello.
How can i run this relays (1+2 and 3+4) at same time?
int relayPin1 = 5; // IN1 connected to digital pin 5
int relayPin2 = 6; // IN2 connected to digital pin 6
int relayPin3 = 7; // IN3 connected to digital pin 7
int relayPin4 = 8; // IN4 connected to digital pin 8
void setup()
{
pinMode(relayPin1, OUTPUT); // sets the digital pin as output
pinMode(relayPin2, OUTPUT); // sets the digital pin as output
digitalWrite(relayPin1, HIGH); // Prevents relays from starting up engaged
digitalWrite(relayPin2, HIGH); // Prevents relays from starting up engaged
pinMode(relayPin3, OUTPUT); // sets the digital pin as output
pinMode(relayPin4, OUTPUT); // sets the digital pin as output
digitalWrite(relayPin3, HIGH); // Prevents relays from starting up engaged
digitalWrite(relayPin4, HIGH); // Prevents relays from starting up engaged
}
void loop()
{
digitalWrite(relayPin1, LOW);
digitalWrite(relayPin2, LOW);
delay(2500);
digitalWrite(relayPin1, HIGH);
digitalWrite(relayPin2, HIGH);
delay(2500);
digitalWrite(relayPin3, LOW);
digitalWrite(relayPin4, LOW);
delay(2500);
digitalWrite(relayPin3, HIGH);
digitalWrite(relayPin4, HIGH);
delay(2500);
}
Is this what you mean?
- Jordo
Look at the "Blink without delay example" in the Arduino IDE.