raptorbasher
New Member
Hi All,
I am writing some code for a lighting timer project and have the core of the code working well, however I am having a little trouble with fading via pwm.
my code looks for the trigger time and sets off incrementing a word variable, which ultimately gets sent to the pwm command as the named variable.
when the lights come up all is well until it rolls over a value and the fade begins over again.
in my code there is a check for max value which also works, but I now realise this is all counting in hex, and the pwm command is expecting decimal values right? so when my value increments it goes over the decimal max 1023.
so I need a little help, I have got the input via buttons and LCD of a percentage, but using BCD, so the max value can have a four digit value xxx.x% and that is okay but how do I...
1, get the increment to happen in decimal? or at least convert it to decimal before incrementing and back again...
2, get the value in decimal to go to the pwm command?
any ideas??
thanks
Tim
I am writing some code for a lighting timer project and have the core of the code working well, however I am having a little trouble with fading via pwm.
my code looks for the trigger time and sets off incrementing a word variable, which ultimately gets sent to the pwm command as the named variable.
when the lights come up all is well until it rolls over a value and the fade begins over again.
in my code there is a check for max value which also works, but I now realise this is all counting in hex, and the pwm command is expecting decimal values right? so when my value increments it goes over the decimal max 1023.
so I need a little help, I have got the input via buttons and LCD of a percentage, but using BCD, so the max value can have a four digit value xxx.x% and that is okay but how do I...
1, get the increment to happen in decimal? or at least convert it to decimal before incrementing and back again...
2, get the value in decimal to go to the pwm command?
any ideas??
thanks
Tim