Created
December 5, 2020 04:03
-
-
Save buildcircuit/01cf41ab85ef9c50d9f1eaa8e8910ca5 to your computer and use it in GitHub Desktop.
Bluetooth and RF module Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****RF SWITCH WITH ARDUINO*/ | |
// The 4 output ports of RF module are connected to A0-A3 | |
//When the Analog pins receive the signal from the RF module, the Arduino activates the corresponding pin. | |
//For example, when A0 receives a signal, it will turn on Arduino Pin number D2 | |
int sensorPin0 = A0; | |
int Pin0 = 2; | |
int sensorValue0 = 0; | |
int sensorPin1 = A1; | |
int Pin1 = 4; | |
int sensorValue1 = 0; | |
int sensorPin2 = A2; | |
int Pin2 = 6; | |
int sensorValue2 = 0; | |
int sensorPin3 = A3; | |
int Pin3 = 8; | |
int sensorValue3 = 0; | |
void setup() { | |
Serial.begin(38400); | |
pinMode(Pin0, OUTPUT); | |
pinMode(Pin1, OUTPUT); | |
pinMode(Pin2, OUTPUT); | |
pinMode(Pin3, OUTPUT); | |
digitalWrite(Pin0, LOW); | |
digitalWrite(Pin1, LOW); | |
digitalWrite(Pin2, LOW); | |
digitalWrite(Pin3, LOW); | |
} | |
void loop() { | |
sensorValue0 = analogRead(sensorPin0); | |
if (sensorValue0>=500) | |
{ | |
digitalWrite(Pin0, HIGH); | |
Serial.println(sensorValue0); | |
delay(100); | |
digitalWrite(Pin0, LOW); | |
} | |
else | |
{ | |
digitalWrite(Pin0, LOW); | |
Serial.print("Value0:"); | |
Serial.println(sensorValue0); | |
} | |
/**********************************************/ | |
sensorValue1 = analogRead(sensorPin1); | |
if (sensorValue1>=500) | |
{ | |
digitalWrite(Pin1, HIGH); | |
Serial.println(sensorValue1); | |
delay(150); | |
digitalWrite(Pin1, LOW); | |
} | |
else | |
{ | |
digitalWrite(Pin1, LOW); | |
Serial.print("Value1:"); | |
Serial.println(sensorValue1); | |
} | |
/***********************************************/ | |
sensorValue2 = analogRead(sensorPin2); | |
if (sensorValue2>=500) | |
{ | |
digitalWrite(Pin2, HIGH); | |
Serial.println(sensorValue2); | |
delay(100); | |
} | |
else | |
{ | |
digitalWrite(Pin2, LOW); | |
Serial.print("Value2:"); | |
Serial.println(sensorValue2); | |
} | |
/***********************************************/ | |
sensorValue3 = analogRead(sensorPin3); | |
if (sensorValue3>=500) | |
{ | |
digitalWrite(Pin3, HIGH); | |
Serial.println(sensorValue3); | |
delay(100); | |
} | |
else | |
{ | |
digitalWrite(Pin3, LOW); | |
Serial.print("Value3:"); | |
Serial.println(sensorValue3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment