Let's Make Robots!

PWM Newbie

First of all I'd like to start by saying I'm new to the robotic/electronic hobby.  About a year ago i started by building fritsl's "Start Here" robot and had a ton of fun doing it.  Thanks for the new hobby fritsl!  I recently started thinking about what else I could do with my PICAXE-28 project board.  I stumbled on a project using PWM to fade an LED.  It looked cool so I thought I would give it a try just for the learning experience.  Unfortunately I can’t get it to work.  I'm obviously not doing something right but I'm not sure what.

I connected the LED to pin 1 (through a 330ohm resistor) and ground.  My code is as follows:

main:

for b1=0 to 255

pwmout 1,255,b1

next

for b1=255 to 0 step -1

pwmout 1,255,b1

next

goto main

 

This is probably a pretty stupid mistake I'm just not seeing it. Any Ideas?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for the quick response Chris.  I was way off on my first try.  I was using using output 1 instead of the input and I ended up with this code.

start:

pmwout  1,255,0

main:

for b1=0 to 255 step 1

pwmduty 1,b1

next b1

for b1=255 to 0 step -1

pwmduty 1,b1

next b1

goto main

 

Cool effect!!! Thanks for your help.  Now the only thing I have to figure out is what I'm going to try next....

Be sure you are going to input 1 not output 1. Next, the pwmout 1,255,0 should go up at the start of the code and pwmduty should be used in the body of the code. That next probably needs a b1 by it. I think that's it --you should be all set.

BTW --all this is assuming you are using a 28x1 chip