Help with logic for optical encoder?


code: [select]
int encoder(){
 
 int read = digitalread(4);
if(read != lastread){
var = 1;
}
 if((var == 1) && (read != lastread)) {
   encoderpos++;
   var = 0;
   lastread = read;
 }

}

 is wrong? can tell me right algorithm?

   the sensor working well, looks encoderpos isn't getting bigger.

there more 1 kind of encoder. please post vendor link encoder.
as example here link quadrature encoder , know if using ?
http://playground.arduino.cc/main/rotaryencoders 


Arduino Forum > Using Arduino > Programming Questions > Help with logic for optical encoder?


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support