How to using the analog output from the photocell and mapping those values to a

How to put in a photocell in the Motor circuit that below showed?
How to using the analog output from the photocell and mapping those values to a PWM signal for the motor driver to change the speed of the motor? With Code for Arduino?

What is your photocell? A Light Dependent Resistor? Google “arduino ldr” for many pages on using an LDR with Arduino.

We will help you but we usually do not write the code for you. There is a lot of example code that comes with the IDE to learn from. Look in Files, Examples.

Connect a LDR between an analog input and ground, setting that pin with pinMode of INPUT_PULLUP and use analogRead to read it. The effective 47k internal pullup will be a reasonable starting value.

Start with code to print readings to the serial monitor so you know what sort of numbers to use in association with the map() function.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.