#include <VirtualWire.h>
int D0 = 7; //
int D1 = 6; //
int D2 = 5; //
int D3 = 4; //
int D4 = 3;
int analog_pin = A0;
byte message[VW_MAX_MESSAGE_LEN];
byte messageLength = VW_MAX_MESSAGE_LEN;
void setup()
{
Serial.begin(9600);
Serial.println("Device is ready");
vw_setup(2000);
vw_rx_start();
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(9, OUTPUT); //PWM MOTOR
pinMode(analog_pin, INPUT); //For INPUT
pinMode(13,OUTPUT);
}
void LED(){
int sensorValue =analogRead(analog_pin);
if(sensorValue >=100)
{
analogWrite(9,255);
delay(4000);
}
}
void loop() {
LED();
if (vw_get_message(message, &messageLength)) // Non-blocking
{
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++)
{
Serial.write(message*);*
_ if(message*=='1')_
_ {*_
* digitalWrite(D0, HIGH);*
* delay(6000);*
* digitalWrite(D0, LOW);*
* digitalWrite(D1, LOW);*
* digitalWrite(D2, LOW);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* }*
_ if(message*=='2')
{*_
* digitalWrite(D0, LOW);*
* digitalWrite(D1, HIGH);*
* delay(1000);*
* digitalWrite(D1, LOW);*
* digitalWrite(D2, LOW);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* } *
_ if(message*=='3')
{*_
* digitalWrite(D0, LOW);*
* digitalWrite(D1, LOW);*
* digitalWrite(D2, HIGH);*
* delay(1000);*
* digitalWrite(D2, LOW);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* }*
_ if(message*=='4')
{*_
* digitalWrite(D0, LOW);*
* digitalWrite(D1, LOW);*
* digitalWrite(D2, LOW);*
* digitalWrite(D3, HIGH);*
* delay(1000);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* }*
_ if(message*=='5')
{*_
* digitalWrite(D0, LOW);*
* digitalWrite(D1, LOW);*
* digitalWrite(D2, LOW);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, HIGH);*
* delay(1000);*
* digitalWrite(D4, LOW);*
* }*
_ if(message*=='6')
{*_
* digitalWrite(D0, LOW);*
* digitalWrite(D1, HIGH);*
* digitalWrite(D2, HIGH);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* }*
_ if(message*=='7')
{*_
* digitalWrite(D0, HIGH);*
* digitalWrite(D1, HIGH);*
* digitalWrite(D2, HIGH);*
* digitalWrite(D3, LOW);*
* digitalWrite(D4, LOW);*
* }*
* }*
* }*
* }*