Show Posts
|
|
Pages: 1 [2] 3 4 ... 7
|
|
16
|
Forum 2005-2010 (read only) / Interfacing / Re: Target following?
|
on: January 05, 2010, 11:20:15 am
|
|
Or you could use an IR Detector placed inside of a short length of opaque tube. When the bot does not detect the IR strobe, it rotates until it does, then drives forward until the IR strobe again is not detected. You can enrich the scheme then by placing two more sensors to the left and right of the "center" sensor. This will tell you which direction the strobe was traveling when it left the center sensor's field of view, and therefore you know which direction to turn to reacquire it.
|
|
|
|
|
20
|
Forum 2005-2010 (read only) / Interfacing / Re: Mouse Scroll Wheel Sensor and Arduino
|
on: December 10, 2009, 11:29:37 am
|
|
That's odd... the getQuadDir() function will return one of 4 values. Either 0 (the wheel didn't move), 1 (the wheel moved clockwise), -1 (the wheel moved counterclockwise) or 999 (a pulse was missed).
The loop() function should only print something to the terminal if something has changed (i.e. the wheel has been turned or a pulse was missed).
Now you're going to make me break out an old mouse, tear out the wheel and try it out! ;-)
|
|
|
|
|
21
|
Forum 2005-2010 (read only) / Interfacing / Re: Mouse Scroll Wheel Sensor and Arduino
|
on: December 10, 2009, 06:53:36 am
|
How about this one: /* Quadrature Example */ int quadAPin = 1; int quadBPin = 2;
int lastQuadValue;
int CLOCKWISE = 1; int CCLOCKWISE = -1; int MISSEDPULSE = 999;
void setup() { lastQuadValue = readQuadValue(); Serial.begin(9600); }
void loop() { int newQuadValue = readQuadValue(); int quadDir = getQuadDir(lastQuadValue, newQuadValue); if (quadDir == CLOCKWISE) Serial.print("Clockwise"); if (quadDir == CCLOCKWISE) Serial.print("Counter Clockwise"); if (quadDir == MISSEDPULSE) Serial.print("Missed Pulse Detected"); lastQuadValue = newQuadValue; }
int readQuadValue() { int val = digitalRead(quadAPin); val = val * 2 + digitalRead(quadBPin); return val; }
int getQuadDir(int prevVal, int newVal) {
//because the step order is 0, 1, 3, 2 lets do some switching around
if (newVal == 3) { newVal = 2; } else { if (newVal == 2) newVal=3; }
if (prevVal == 3) { prevVal = 2; } else { if (prevVal == 2) prevVal=3; } int quadDir = prevVal - newVal; //see if we missed a pulse (i.e. quadDir is 2 or -2) if (abs(quadDir) == 2) quadDir = MISSEDPULSE; return quadDir; }
I haven't actually tried it, but it should work.
|
|
|
|
|
22
|
Forum 2005-2010 (read only) / Interfacing / Re: Mouse Scroll Wheel Sensor and Arduino
|
on: December 09, 2009, 06:31:00 pm
|
|
The answer is "Quadrature". Here have a look at this: http://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder
The three contacts serve as two bits, with one contact being common. With two bits, you have 4 possibilities... 00, 01, 10, 11. The order they appear in tells you the direction.
|
|
|
|
|
27
|
Forum 2005-2010 (read only) / Interfacing / Re: please help fast!!
|
on: December 03, 2009, 07:57:15 pm
|
|
Holy cow they are! I never noticed that before. I'm just in the habit of just grabbing the data-sheet to look at before I hook anything up. I never noticed that they are exactly backwards of one another.
|
|
|
|
|
30
|
Forum 2005-2010 (read only) / Interfacing / Re: I'm Confused DS1307 & LCD
|
on: November 27, 2009, 07:21:45 pm
|
There are definitely issues with the standard LiquidCrystal library when used in conjunction with the Wire library. Reading this thread leads me to believe the conflict does not exist between the 4BitLCD library & the Wire library. I haven't yet tried swapping it out however, but it is my intention to do so.
|
|
|
|
|