Created
December 26, 2017 06:42
-
-
Save elktros/0e5b277804e3c137209fbda5bb1b3d30 to your computer and use it in GitHub Desktop.
Code for Transmitter part of the Arduino Home Automation using RF Module Project.
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
#include <VirtualWire.h> | |
const int RF_TX_PIN = 8; | |
const int load1_ON = 6; | |
const int load1_OFF = 5; | |
const int load2_ON = 4; | |
const int load2_OFF = 3; | |
char msg[6] = ""; | |
int load1ON = 0; | |
int load1OFF = 0; | |
int load2ON = 0; | |
int load2OFF = 0; | |
void setup() | |
{ | |
vw_set_ptt_inverted(true); | |
vw_set_tx_pin(RF_TX_PIN); | |
vw_setup(2000); | |
pinMode(load1_ON, INPUT); | |
pinMode(load1_OFF, INPUT); | |
pinMode(load2_ON, INPUT); | |
pinMode(load2_OFF, INPUT); | |
} | |
void loop() | |
{ | |
load1ON = digitalRead(load1_ON); | |
load1OFF = digitalRead(load1_OFF); | |
load2ON = digitalRead(load2_ON); | |
load2OFF = digitalRead(load2_OFF); | |
if (load1ON == HIGH) | |
{ | |
strcpy(msg, "@ABC$"); | |
} | |
if (load1OFF == HIGH) | |
{ | |
strcpy(msg, "@BOFF$"); | |
} | |
if (load2ON == HIGH) | |
{ | |
strcpy(msg, "@FON$"); | |
} | |
if (load2OFF == HIGH) | |
{ | |
strcpy(msg, "@FOFF$"); | |
} | |
if(strlen(msg)>0) | |
{ | |
sendMsg(msg); | |
} | |
strcpy(msg, ""); | |
resetLoads(); | |
} | |
void sendMsg(char msg[]) | |
{ | |
vw_send((uint8_t *)msg, strlen(msg)); | |
vw_wait_tx(); | |
delay(400); | |
} | |
void resetLoads() | |
{ | |
load1ON = 0; | |
load1OFF = 0; | |
load2ON = 0; | |
load2OFF = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
man hello, i really need ur help
Can u make code for arduino using 2 sensors and 2 wheels to make arduino line follower, but it should follow the line when 2
sensors are on it)HELP PLS