Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char val; // Data received from the serial port
- long int inByte;
- void setup()
- {
- //initialize serial communications at a 9600 baud rate
- Serial.begin(9600);
- establishContact(); // send a byte to establish contact until receiver responds
- }
- void loop()
- {
- if (Serial.available() > 0) { // If data is available to read,
- // get incoming byte:
- inByte = Serial.read();
- if (inByte == 'w') {
- //Do Stuff
- delay(100);
- }
- if(inByte == 'a'){
- //Do Stuff
- }
- else {
- Serial.println("Awaiting commands"); //send back a hello world
- delay(10);
- }
- }
- }
- void establishContact() {
- while (Serial.available() <= 0) {
- Serial.println("A"); // send a capital A
- delay(300);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement