The PWM/analogWrite pins on a Nano have a tilde in front of their pin numbers:
Wow... analog pins are for input. PWM is a digital signal. I should have known that. Thank you
for analog input
That is just one of the functions they can do. They can also function as digital input or output. As noted by @runaway_pancake above, this is true for A1..A5 but not tur for A6 and A7 which are analog inputs only.
Thank you for the help
@blh64 , Thank you for the explanations. all the help means a lot.
@DaveX ,
This is a great idea. I will try this out next as a way to make the motors run at variable speeds.
Thank you for including the constrain function. I was wondering if that would be necessary as the sensor will provide readings as high as 790 and I've read if you don't tell the microcontroller what to do with those readings, it will come up with something for you.
map works out the multiplier and offset to make the conversion, so with these parameters:
The something it would come up with is that the map() would convert 790 into 790 * (-255/120)+255=-1423
, and then since PWM only takes a uint8_t byte it drops all the high bytes and keeps only the 113 in the low byte.
@DaveX ,
Thanks for the explanation. Does it kick out 113 as unsigned? or is it -113 after dropping the 4 bits?
You should not mixup A6-pin with D6-pin (aka DPin-6) of Arduino NANO (Fig-1). You are expecting PWM signal on D6/DPin-6 and NOT on A6-pin. The analogWrite() function does not output PWM signal on A6-pin.
Figure-1:
Thank you for taking the time to draw this illustration. @DaveX showed me this error on post#21. I appreciate how helpful everyone is on this forum.