I'm sorry if this is a weird question. I have this project from my school. Here's my setup:
- Seeeduino Stalker v3
- UartSBee v.4
- RF_2530 or known as CC2530 (maybe)
- Arduino Duemilanove
- 2-channel relay shield
So on the first image I have the RF2530 attached to my relay shield and also attached to my Arduino.
On my second image, the RF2530 is attached to the UartSBee.
And lastly I have my Seeeduino connected to the UartSBee by using jumper wire:
Seeeduino----------UartSBee
5v-----------------------VCC
TX-----------------------RX
RX-----------------------TX
GND---------------------GND
DTR----------------------DTR
My goal is, the Seeeduino will receive a GPIO pin from another device, for example if the Seeeduino receives pin 4 HIGH, the LED of RELAY1 will turn on, or if the Seeeduino receives pin 4 LOW, the LED of RELAY1 will turn off.
My problem is, if for example the Seeeduino receives pin 4 HIGH, the relay1 LED doesn't turn on.
Here's my code:
const int relay1 = 4;
const int relay2 = 5;
void setup(){
Serial.begin(57600);
pinMode(relay1, INPUT);
pinMode(relay2, INPUT);
}
void loop(){
digitalRead(relay1);
digitalRead(relay2);
if(relay1 == 1) {
Serial.println("#M9"); //relay1 HIGH,turn on relay 1 LED
}
if(relay1 == 0) {
Serial.println("MA"); // relay1 LOW,turn off relay 1 LED
}
if(relay2 == 1) {
Serial.println("#MB"); //relay2 HIGH,turn on relay 2 LED
}
if(relay2 == 0) {
Serial.println("MC"); //relay2 LOW,turn off relay 2 LED
}
return 0;
}
Can someone point out what I'm missing? Any advice would be helpful. Thank you.