Created
January 28, 2020 20:17
-
-
Save futureshocked/19485984d96a0b8bfcc0a361e7fbc76f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (); | |
| Serial.print("Sending:"); | |
| Serial.print(message); | |
| Serial.print(" "); | |
| radio.write( &message, 1 ); | |
| // Now, continue listening | |
| radio.startListening(); | |
| // Wait here until we get a response, or timeout (250ms) | |
| unsigned long started_waiting_at = millis(); | |
| bool timeout = false; | |
| while ( ! radio.available() && ! timeout ) | |
| if (millis() - started_waiting_at > 200 ) | |
| timeout = true; | |
| // Describe the results | |
| if ( timeout ) | |
| { | |
| Serial.println("Failed, response timed out."); | |
| } | |
| else | |
| { | |
| // Grab the response, compare, and send to debugging spew | |
| byte response; | |
| radio.read( &response, sizeof(response) ); | |
| Serial.print("Transmitter. Received response from receiver:"); | |
| Serial.println(response,BIN); | |
| if (response == B0) | |
| { | |
| digitalWrite(led_pin,HIGH); | |
| Serial.println("Ok"); | |
| } | |
| else | |
| { | |
| digitalWrite(led_pin,LOW); | |
| Serial.println("No connection"); | |
| } | |
| } | |
| // Try again later | |
| delay(150); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment