Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int gearcounter = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(A1, INPUT); // Ir sensor pin
- pinMode(5, OUTPUT); // Mosfet gate pin
- }
- void loop() {
- gear10us = analogRead(A1);
- delayMicroseconds(10)
- if (gear10us != analogRead(A1)){
- //gear moving in the last 10 micro seconds
- gearcounter += 1;
- }
- if (gearcounter == 16) {//Maximum gear is 16, I just want to stop it one before the maximum
- gearcounter = 1;
- }
- while(gearcounter < 15){
- digitalWrite(5, HIGH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement