Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int in=2;
- void setup(){
- Serial.begin(9600);
- pinMode(in, INPUT);
- }
- int temi=0;
- int tfin=0;
- boolean alto=false;
- void loop(){
- }
- void serialEvent() {
- if(Serial.read()=='a'){
- temi=millis();
- while(digitalRead(in)==LOW && Serial.read()!='c'){
- alto=true;
- tfin=millis();
- }
- if(digitalRead(in)==HIGH && alto){
- int res=tfin-temi;
- Serial.println(res);
- alto=false;
- }
- temi=0;
- tfin=0;
- }
- if(Serial.read()=='b'){
- temi=0;
- tfin=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement