Wheel Encoders for DFRobot 3PA and 4WD Rovers (SKU:SEN0038)
Contents
1 Introduction
1.1 Specification
1.2 Sample Code
2 Assembly Guide
3 FAQ
4 Encoder Schematics
Introduction
This encoders are designed for DFRobot 3PA and AWD Rovers. It can give you the rotation degree
of the wheels. Encoder uses non-contact method to convert the angular displacement signals. Best
fit with Micro DC Geared Motor.
It includes encoders, plastic tube, paper-mediated gasket etc.
Specification
Voltage:+5V
Current: Digital pin 2
// #
right wheel encoder -> Digital pin 3
// # Note: If your controller is not 328-based, please check https://www.ardu
ino.cc/en/Reference/AttachInterrupt for proper digital pins.
#define LEFT 0
#define RIGHT 1
long coder[2] = {
0,0};
int lastSpeed[2] = {
0,0};
void setup(){
Serial.begin(9600);
int the data
//init the Serial port to pr
attachInterrupt(LEFT, LwheelSpeed, CHANGE);
r the digital pin 2
//init the interrupt mode fo
attachInterrupt(RIGHT, RwheelSpeed, CHANGE);
r the digital pin 3
//init the interrupt mode fo
}
void loop(){
static unsigned long timer = 0;
//print manager timer
if(millis() - timer > 100){
Serial.print("Coder value: ");
Serial.print(coder[LEFT]);
Serial.print("[Left Wheel] ");
Serial.print(coder[RIGHT]);
Serial.println("[Right Wheel]");
lastSpeed[LEFT] = coder[LEFT];
//record the latest speed value
lastSpeed[RIGHT] = coder[RIGHT];
coder[LEFT] = 0;
//clear the data buffer
coder[RIGHT] = 0;
timer = millis();
}
}
void LwheelSpeed()
{
coder[LEFT] ++;
//count the left wheel encoder interrupts
}
void RwheelSpeed()
{
coder[RIGHT] ++; //count the right wheel encoder interrupts
}
Assembly Guide
Step1:
Step2:
Step3:
FAQ
Serial monitor
Q. The feedback value is full that the Serial monitor is always printing value around 25903 and
25344, no matter of the motor running or not.
A. The first parameter in the interrupt function ' attachInterrupt ' means the interrupt number
that is just number 0 and 1, not the interrupt pin number.read more
Encoder Schematics
Powered By DFRobot © 2008-2016
很抱歉,暂时无法提供与“SEN0038”相匹配的价格&库存,您可以联系我们找货
免费人工找货