Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long previousMillis = 0;
- const long interval = 250;
- int responseO;
- int responseR;
- void setup() {
- Serial.begin(9600);
- while (!Serial);
- }
- void loop() {
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis >= interval) //timer for every 250ms
- {
- previousMillis = currentMillis;
- Serial.println("R"); //Figured that "println" with a string for the character R should be ok
- if(Serial.available() >0) //Don't know if I am correct here, I was hoping that the serial would only be read if the device responded to the command R
- {responseR = Serial.read();} //Read serial for device's response to command R and save it in a variable
- Serial.println("O"); //Do the same thing for the command O
- if(Serial.available() >0)
- {responseO = Serial.read()}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement