Quantcast
Channel: Sensors - Arduino Forum
Viewing all articles
Browse latest Browse all 1152

Linear laser encoder

$
0
0

Good day. I purchased a linear encoder.


Trying to test it, I assembled the following circuit.

I wrote the following code

int PinA = 12;
int PinB = 2;
int val = 0;
int val2 = 0;

void setup(void) {
 Serial.begin(9600);
 pinMode(PinA, INPUT_PULLUP);
 pinMode(PinB, INPUT_PULLUP);
}

void loop(void) {
 val = digitalRead(PinA); 
 val2 = digitalRead(PinB); 
 
 Serial.print("A value: ");
 Serial.print(val);
 
Serial.print("\tB value: ");
 Serial.println(val2);
}

I get the following result
image
Channel B reacts to changes and changes 1 to 0 when touched by the laser. Channel A does not react to anything, it constantly hangs at 0. I think maybe I screwed up somewhere in the connection diagram. Does anyone have an idea why channel A does not work? And what is this 5 channel that says that it is a reference channel, no matter how I connect it to + and -, it does not affect anything.

3 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 1152

Trending Articles