that_one_nigga_you_k

código 37

Apr 1st, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. int A, B, i=0;
  2.  
  3. void setup() {
  4.   // put your setup code here, to run once:
  5.   pinMode(4, INPUT);
  6.   pinMode(3, INPUT);
  7.   Serial.begin(38400);
  8.   //attachInterrupt(digitalPinToInterrupt(2), blink, CHANGE);
  9.   //attachInterrupt(digitalPinToInterrupt(3), blink, CHANGE);
  10. }
  11.  
  12. void loop() {
  13.   // put your main code here, to run repeatedly:
  14.  
  15.   int ia = i;
  16.  
  17.  
  18.   if(A==B){
  19.     if(A!=digitalRead(4)){
  20.       i++;
  21.       A = digitalRead(4);
  22.     }
  23.     if(B!=digitalRead(3)){
  24.       i--;
  25.       B = digitalRead(3);
  26.     }
  27.   }
  28.  
  29.   else{
  30.     if(A!=digitalRead(4)){
  31.       i--;
  32.       A = digitalRead(4);
  33.     }
  34.     if(B!=digitalRead(3)){
  35.       i++;
  36.       B = digitalRead(3);
  37.     }
  38.   }
  39.  
  40.   if(i != ia){
  41.   Serial.print("\n\n\n\n\n\n\n\n\n\n pulsos:");
  42.   Serial.println(i);
  43. }
  44. }
Add Comment
Please, Sign In to add comment