WheelEncoder Class
- ID: wheelencoder
- Name: Wheel Encoder
- Category: other
- Manufacturer: dfrobot
- Link: http://www.dfrobot.com/index.php?route=product/product&product_id=98
- Connection: gpio
This sensor was developed for the DFRobot Wheel Encoder, though it could be used for any counting time-based task.
When you instantiate a class of this type, the gpio pin specified is connected to an interrupt. Whenever a low to high transition occurs on the gpio pin, the internal counter is incremented by one.
This class also includes a millisecond counter, so that you can correlate the number of counts to a time period for calculating an RPM or other value as needed.
Item Index
Methods
WheelEncoder
-
pin
DFRobot Wheel Encoder sensor constructor
Parameters:
-
pin
NumberDigital pin to use
Returns:
getMillis
()
Number
Returns the number of milliseconds elapsed since initClock() was last called.
Returns:
Elapsed milliseconds
initClock
()
Resets the clock
clearCounter
()
Resets the counter to 0. The counter should be stopped via stopCounter() prior to calling this function.
startCounter
()
Starts the counter. This function will also clear the current count and reset the clock.
stopCounter
()
Stops the counter
counter
()
Number
Gets the current counter value
Returns:
counter value