How to use potentiometers on 8Mhz arduino microcontroller

Hello,

I have a question about how to use a potentiometer.
Everything works fine when using the usual code of " sensorValue = analogRead pot..... analogWrite(motor, outputValue)" on arduino nano board 16Mhz.

Now I have programmed an atmega328 chip at 8Mhz in order avoid using the external crystal on my circuit.
Everything works just fine except the potentiometer. It is only switched from low to high.

Any suggestions about this issue?
Regards
Nicos

It should work the same, regardless of the speed of the clock.

Something else is going on. Can you show a schematic of your custom board, a pcb layout, a photo, and the sketch that shows the problem.

May I make a guess ? Not all pins can do PWM for the analogWrite(). If you choose the wrong pin, then it is only high or low.

Dear Koepel, you just have opened my eyes. Due to the complexity of the circuitry I missconnected the output pin to D7 instead of D9 which is PWM output.

Silly one but sometimes mind stuck!
Thanks again

By the way, I got the same problem with other AVR microcontrollers like Attiny406 and the compatible arduino board MH-Tiny.
I brogramming them through Arduino IDE with similar effect. I have tried all pins as inputs and outputs without any success.

MH-Tiny gives as digital PWM output the pins 9 and 10.

Maybe any possible solutions in that one?
Regards

Stick with the official supported Arduino boards.
It depends on the MH-Tiny software core (the build environment with libraries) what it can do.
Is there a official website for the MH-Tiny ?
Does it have a software USB ? I would stay away from that.

Yeah, well they just droped in my hands so I give them a try. However, I am really in interested of use other microcontrollers more than the Attiny85. Atmega328 are hard to find so I am in a need of other compatible and easy to find microcontrollers. Attiny406 and other similar to that are really easy to get programmed through Arduino IDE by UPDI method. But I am always in a luck with the potentiometer map reading.