Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Picaxe 08m2+ and RGB led

Status
Not open for further replies.

rudster

New Member
Hey,
My project is to get 4 RGB leds to go throuhg the rainbow spectrum useing a picaxe 08m2+ and two SN74HCT244 octal buffers. I attached a schematic but my main problem is the code.
I'm having trouble writing it up and when I do practice runs the LEDs flicker while fading during dim.
heres what I have so far not much wondering if anything can help. Thanks!

Code:
#picaxe 08m2

symbol	REDLED = 2
symbol	GRNLED = 1
symbol	BLULED = 4


symbol	SPEED = 10

low BLULED
low REDLED
cycle:

	b0 = GRNLED : call fadeup 
	b0 = GRNLED : call fadedown
	return

fadedown:
	for b1 = 0 to 255
		pwm b0, b1, SPEED
	next
	high b0
	
	return
	
fadeup:
	for b1 = 255 to 0 step -1
		pwm b0, b1, SPEED
	next
	low b0
	
	return





**broken link removed**
 
You need to set the color on and use PWM on the ground if you want it to fade with out flicker.
 
You have 3 outputs R,G,B. If you only use 0 or 1 you will only get 8 colors. Black......White.

If you PWM the outputs you can get 1000s of colors with only three outputs.
With in 1/100 of a second, you can have G=on, R=on for 2/1000 of a second and B=on for 6/1000 of a second.
 
I would set the colors bit bang pwm and fade with the ground using hardware pwm
 
Thanks for your help guys, I found some sample codes online and trying to play with it, this is working alright but still some flickering.
If you can show some pseudocode or explain a little more on how to use the ground as pwm that'll be great
Sorry for the trouble, I just cant seem to get it
Thanks again!

Code:
#picaxe 08m2

symbol	REDLED = 2
symbol	GRNLED = 1
symbol	BLULED = 4


symbol	SPEED = 10
symbol	REDLEVEL = w3
symbol	REDDIR = b2


main:

	setfreq m8

	do

	

	
		
		
		; begin colour fading
		REDLEVEL = 800
		REDDIR = 0
		pwmout REDLED, 200, REDLEVEL
				
		do while REDLEVEL > 0

			call cycle
	
		loop
		
		pwmout REDLED, off
	
	loop
	
cycle:

	b0 = GRNLED : call fadeup 
	b0 = BLULED : call fadeup 
	b0 = GRNLED : call fadedown
	b0 = BLULED : call fadedown
	b0 = REDLED : call fadedown
	return

fadedown:
	for b1 = 0 to 255
		pwm b0, b1, SPEED
	next
	high b0
	Call fadered
	return
	
fadeup:
	for b1 = 255 to 0 step -1
		pwm b0, b1, SPEED
	next
	low b0
	Call fadered
	return

fadered:
	if REDDIR = 1 Then
		if REDLEVEL = 800 then
			REDDIR = 0
		else
			REDLEVEL = REDLEVEL + 25
		endif
	else
		if REDLEVEL = 0 then
			REDDIR = 1
		else
			REDLEVEL = REDLEVEL - 25
		endif
	endif
	pwmduty REDLED, REDLEVEL
	return
	
end
 
Status
Not open for further replies.

Latest threads

Back
Top