The 40x1 has 2 PWM pins. I have the code pwm 1, b2, 1 but I think I need to tell the picaxe that I want to use the pin as PWM since it can also be an output or input pin. Any ideas?
Isn’t CtC using PWM to drive
Isn’t CtC using PWM to drive the multi-color LEDs on Walter? Perhaps he’s got some good info posted.
I have had better luck…
I have had better luck using the pwmout as an init. and from there using the pwmduty command. You don’t need to tell the picaxe to change the pin it goes to PWM as soon as you use the command. Oh, and the variable should be at the end. Use the pwm wizard, it will help a lot.
Also, I use this: pwmout pin,63,b1 --the “63” puts the variable in a range of 0 to 255. 0 is off and 255 is full speed. Obviously, 0 to 255 is a little easier to work with when writing code.
Did you use it to drive
Did you use it to drive LEDs? Any code snippets you can send me?
I did use it to drive the
I did use it to drive the eyes, and for the drive wheels. I checked my code and for the eyes I guess I am using pulsout pin,49,b1. The diference between th 63 I stated above and the 49 now is probably the difference between an x1 and x2 (4mhz and 8mhz). In ether case, use the wizard to find out what # gives you a range between 0 and 255 --it will make everything else easier…
Code:
init:
pwmout 1,49,0
pwmout 2,49,0
main:
for b1=0 to 255 step 1
pwmduty 1,b1
pwmduty 2,b1
pause whatever
next b1
for b1=255 to 0 step -1
pwmduty 1,b1
pwmduty 2,b1
pause whatever
next b1
goto main
This should be a simple fade up/ fade down. There you go!
Were your eyes tri-color
Were your eyes tri-color LEDs or just LEDs? I’m trying to figure out how changing the desired PWM frequency would affect my tri-color LEDs. The default is 10000 Hz.
Tri-colour LEDs are normally
Tri-colour LEDs are normally just 3 LED dies in a single package, so they behave the same as 3 seperate LEDs. Changing the PWM frequency won’t have a significant effect unless you’re below ~60Hz.