SX28 Microcontroller - Bycicle counter with Hall-sensor
afkiss
Posts: 3
I wanted to make a counter for my bike with a TLE4905 Hall-sensor. First, I wrote a program which turned on a led, when I toke a magnet to the sensor (it worked good), but when I wrote a new program with a counter that didn't work. I still want to write a counter because I want to count the rev (I don't know, what's the good word for this) of my bike. If you can help me with the program, please write!
Comments
Bean
You should set counter to zero before the loop.
You need to wait for the sensor to be off. As it is now the counter will increase every time through the loop as long as the sensor is on.
I would make a variable to hold the last sensor state, then you can say if the last state was off, and the current state is on, then increase the counter.
Bean