Member Avatar for alias_neo

Hey guys, I'm looking to make some pulsing LEDs and I believe PWM is the way to do it, I'm new to ASM and don't really know how it works. Datasheet is like reading chinese to me. Could anyone please help me out with how to get started?

Well, If you don't want to start with asm, you could use BASIC. You don't need PWM if you just want to turn LEDs on and off. Any fixed square wave will do it. In other words, just toggle the pins. There's a free version of the Swordfish compiler you could use if you want to get started in basic.

Member Avatar for alias_neo

Well, If you don't want to start with asm, you could use BASIC. You don't need PWM if you just want to turn LEDs on and off. Any fixed square wave will do it. In other words, just toggle the pins. There's a free version of the Swordfish compiler you could use if you want to get started in basic.

HEY, thanks for the suggestion. I would rather use ASM, I'm already familiar with BASIC and use it quite a lot but am currently learning ASM. Thought making a little something for my girlfriend would be a good project. Like I said though, I want to "pulsate" the LEDs rather than just turning them on and off, how simple is it to just flicker them on and off quickly with a square wave like you say and have them go brighter and dimmer. The thing is, obviously, the LEDs aren't the whole project so i need the rest of the program to be running at the same time, I can't spend the whole process time dong the dimming/brightening etc because it has to do other things. The Diming is the only part I'm not too sure how to do, the rest shouldn't be a problem. I have some example code for the PWM that I threw together from the datasheets and I can get an LED to light at varying brightnesses but it is fixed and i can't seem to vary it in runtime by changing the duty cycle. It just doesn't seem to update.

I can post the code if anyone thinks they can help. Thanks

What you normally do is create a timer interrupt to control the pulse width, so the processor can be doing something else.
I haven't used Microchip's line of micros yet so pic asm is gibberish to me.
Have you seen this turorial http://www.iguanalabs.com/pwm.htm
The code isn't for PICs, it's for 8051s but it explains it well.
This tutorial shows how to use the PWM hardware of a certain 16F to generate the signals.
http://www.winpicprog.co.uk/pic_tutorial8.htm
If you get stuck, these forums are the best to try IMO.
http://www.electro-tech-online.com/
Give a search of the forum for PWM, or post your code. There's a lot of PIC enthusiasts there. The forums here are more for x86.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.