Hello! I'm still quite new here. I'm trying to make a prototype of my schematic that involves a photointerrupter (QVA11134). This is the schematic basically(R2 is 1k ohm), I just duplicate it because my project needs two of it. This is code :
int sensorValue = 0;
int Read0;
int Read1;
void setup() {
pinMode(A0, INPUT);
pinMode(A1, INPUT);
Serial.begin(9600);
}
void loop() {
Read0=analogRead(A0);
Read1=analogRead(A1);
Serial.print (" ");
Serial.println(Read0);
Serial.print(Read1);
delay(100);
}
My problem is,when I ran the serial monitor, everything reads 0,but when I pressed the back of my perfboard(which is connecting pin 4s and the one that goes to A0/A1 in Arduino), it reads a number depending on how hard I pressed it with my human hand only, for example if I press lightly it reads 10,if I press hard it reads 50,etc. But it wouldn't work if I press it with anything else other than my bare hand. I also tried to remove the photointerrupter and it still happens,so I assume the photointerrupter is not connected at all to the circuit.
So, can I connect the photointerrupter with jumper wires like this?
If not then,how can I connect it? Also it would help tremendously if you can help me identify the problem!
I'm using Arduino Uno.