Hello there. I'm working on a project where I use an ESP8266 and a nodeMCU. I'm basically trying to make a simple line-follower robot, that's why I'm using two IR sensors TCRT5000. I put one on each side of the robot, and when one of them detects the line (one sensor doesn't sees the green field but the black line), the robot makes a turn in the right dirction.
I tried using them with the digital pins of the nodeMCU, but for several reasons that doesn't go well with my project. In general, even when I change the sensibility of the sensor, it cannot detect the small black line on the ground. Moreover, it can only detect a change of colour (any color to white or any color to black), basically 0 or 1.
That's why I tried using the analog pin of the nodeMCU, and it works perfectly! I take note of the values that my sensors "see" to follow the line, and I just need to note the range of values that I need. My code basically looks like
if((sensor1>27)&&(sensor1<35))
turnright();
(it's not the exact code, but I hope i'm clear...)
However, my problem is that there is only one analog pin on this NodeMCU, so I can only plug one sensor... Is there a way to use a digital pin as an analog pin, or to return the values I need? Or do I need a multiplexer (this option is available for me only if I really don'thave another choice...)
I would really appreciate if you have any tips or ideas regarding all this!