Maybe the simplest thing is to start with the basic.
First use a multimeter and check the signal if it toggles near 0V and near 3.3V.
Since your gpio20 and 21 a simple C code with pigpio just to check if the sensors works once you figure it out the problem with the multimeter.
First use a multimeter and check the signal if it toggles near 0V and near 3.3V.
Since your gpio20 and 21 a simple C code with pigpio just to check if the sensors works once you figure it out the problem with the multimeter.
Code:
daniel@benchpi4:~ $ cat TestOpticSensor.c#include <stdio.h>#include <pigpio.h>#include <stdlib.h>#include <unistd.h>#define Sensor1 20#define Sensor2 21int main(void){// initialize GPIO if(gpioInitialise() < 0) return 1; gpioSetMode(Sensor1, PI_INPUT); gpioSetMode(Sensor2, PI_INPUT); gpioSetPullUpDown(Sensor1, PI_PUD_UP); gpioSetPullUpDown(Sensor2, PI_PUD_UP); while(1) { printf(" sensor1(gpio%d):%d, sensor2(gpio%d):%d\n", Sensor1,gpioRead(Sensor1), Sensor2,gpioRead(Sensor2)); usleep(500000); } return 0;}
Statistics: Posted by danjperron — Wed Mar 13, 2024 12:40 am