Skip to content

Chelseasingla1/Communication-between-two-robots-task-7.2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

#include <VirtualWire.h> #include <VirtualWire_Config.h>

char input; char *data;

void setup () { pinMode (4, OUTPUT); //left motors forward pinMode (6, OUTPUT); //left motors reverse pinMode (10, OUTPUT); //right motors forward pinMode (11, OUTPUT); //right motors reverse

Serial.begin(9600);

vw_set_rx_pin(3); vw_setup (2000); pinMode(3,INPUT); vw_rx_start(); }

void loop() { uint8_t buf[VW_MAX_MESSAGE_LEN]; uint8_t buflen=VW_MAX_MESSAGE_LEN; Serial.println(buf[0]); if(vw_get_message(buf,&buflen)){ if(buf[0]=='f') { forward(); } else if(buf[0]=='g') { backward(); } else if(buf[0]=='l') { left(); } else if(buf[0]=='r') { right();
} else if(buf[0]=='s') { stop(); }

} }

void forward() { digitalWrite(6, LOW ); digitalWrite(4, HIGH); digitalWrite(10, HIGH); digitalWrite(11, LOW); }

void stop() { digitalWrite(6, LOW ); digitalWrite(4, LOW); digitalWrite(10, LOW); digitalWrite(11, LOW); }

void backward() { digitalWrite(6, HIGH ); digitalWrite(4, LOW); digitalWrite(10, LOW); digitalWrite(11, HIGH); }

void right() { digitalWrite(6, HIGH ); digitalWrite(4, LOW); digitalWrite(10, HIGH); digitalWrite(11, LOW); }

void left() { digitalWrite(6, LOW ); digitalWrite(4, HIGH); digitalWrite(10, LOW); digitalWrite(11, HIGH); }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published