Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int incomingByte = 0;
- void setup(){
- Serial.begin(9600);
- while (Serial.available() <= 0) {//keep sending until we get some bytes from the pc
- Serial.write(42); // just a constant
- delay(100);
- }
- while(Serial.available()>0) Serial.read(); //immediately after we get something from the PC clear the input buffer by reading from it until it's empty
- }
- void loop(){
- if (Serial.available()>0) {
- incomingByte=Serial.read();
- delay(incomingByte*50); //simulate waiting for a physical event
- Serial.write(incomingByte);//echo the input byte
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement