Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- //Initiating serial communication and flushing serial port, just for good measure
- Serial.begin(9600);
- Serial.flush();
- }
- byte expected_byte1 = 0x31;
- byte expected_byte2 = 0x32;
- void loop() {
- // Check if there is something on the serial port
- if (Serial.available()) {
- //read available data, save to recieved_data
- int recieved_data = Serial.read();
- //does the recieved data match our expectations?
- if (recieved_data == expected_byte1) {
- Serial.print("You sent the number 1!");
- delay(50);
- }
- //Other expectation for concept purposes
- if (recieved_data == expected_byte2) {
- Serial.print("You sent the number 2!");
- delay(50);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment