I'm relatively new to micro-controller programming and recently decided to use an Arduino for a simple project. I was wondering if someone can help me or direct me to relevant links on this forum. My Arduino UNO (rev2) project is to make a system that consists of:
-
single encoder (Alps SRGPSJ) glued to a wheel to measure rotations of the wheel in order to find the distance it goes.
-
a display to show the distance(s). For prototyping, I'm using a 4 digit seven-segment display (HDSP-B0xE). Some have suggested that an LCD may be easier, so I've ordered two of these for later use:
http://arduino.cc/en/Tutorial/LiquidCrystal
(1602 Character LCD Display Module HD44780) -
An actuation switch (Honeywell V15T16-CZ300A03-K) to indicate to the system to record the distance when switched on
-
A reset button (Mountain 103-1218-EVX) for resetting the distance count.
I've gotten the encoder to display some signals, but not all and I suspect it may need debouncing, as indicated to me here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205879808/all
A sample of my code is:
/* Encoder Test Code 1 */
int EncA = 7;
int EncB = 8;
int EncPos = 0;
int EncALast = LOW;
int n = LOW;
int Rev = 0;
void setup () {
pinMode (EncA, INPUT);
pinMode (EncB, INPUT);
Serial.begin (9600);
}
void loop () {
n = digitalRead(EncA);
if ((EncALast == LOW) && (n == HIGH)){
if (digitalRead(EncB) == LOW) {
EncPos--;
} else {
EncPos++;
}
Rev = EncPos/16;
Serial.print (EncPos
);
Serial.print ("/");
}
EncALast = n;
}
Any help is greatly appreciated, as I'm somewhat clueless on how to connect some of these devices together to make the system work. Also, if possible, let me know where I need resistors or transistors, or any other component.
I've done a search on some of these devices and they've given me different information. Thanks!!