Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. int gearcounter = 0;
  2.  
  3.  
  4. void setup() {
  5. Serial.begin(9600);
  6. pinMode(A1, INPUT); // Ir sensor pin
  7. pinMode(5, OUTPUT); // Mosfet gate pin
  8.  
  9. }
  10.  
  11. void loop() {
  12. gear10us = analogRead(A1);
  13. delayMicroseconds(10)
  14. if (gear10us != analogRead(A1)){
  15. //gear moving in the last 10 micro seconds
  16. gearcounter += 1;
  17. }
  18.  
  19. if (gearcounter == 16) {//Maximum gear is 16, I just want to stop it one before the maximum
  20. gearcounter = 1;
  21. }
  22.  
  23.  
  24. while(gearcounter < 15){
  25. digitalWrite(5, HIGH);
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement