Last active
July 24, 2016 08:10
-
-
Save dsouzadyn/2184e060018c39f9ceb7eabeedcf4d98 to your computer and use it in GitHub Desktop.
Robocon Assignment
This file contains 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
int count = 0; | |
int sum = 0; | |
byte a; | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
/* | |
* Check if data is available for reading on the Serial Port. | |
*/ | |
if(Serial.available()) | |
{ | |
a = Serial.read() - 48; | |
sum = sum*10 + a; | |
count = count + 1; | |
delay(50); | |
} | |
/* | |
* If the count which indicates the number of digits is 3, print the number. | |
*/ | |
if(count == 3) | |
{ | |
Serial.println(sum); | |
sum = 0; | |
count = 0; | |
} | |
delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixes