RGB color selector by the click of a button

vladthegreat1

New Member
I dont know if the person who made this video is a part of this forum but i have tried to get a hold of him on youtube with no luck.
Can anyone help me with the code on this one? I think i got the correct inputs and outputs but I am just learning the coding for picaxe but so far i am having a blast. but i cant quite figure out what needs to happen.
Will post my code that i have so far when i get home.




accidently posted this in the finshed projects forum, so if an admin see's this first can you please remove that other post ?
 

Goeytex

Senior Member
Looks like another one of those "Look at me!" videos with no information.

Post your schematic and the code you have done so far and I think the "collective" here can help you. It might also be helpful to know what Picaxe you are using and what LED you have.
 

vladthegreat1

New Member
well damn! looks like it did not save anywhere.. ffs, i am going to rewrite it again .
I have the 08m2 and it is an RGB LED (smd) type that i have on a breadboard type copper board with 4 wires from the led coming out.

let me recreate my code because i cant find it anywhere now even though i know i saved it.
 

Jeff Haas

Senior Member
Do you mind if we guess at the approach he's taking in the video? Could be fun...

Observations:
- There only seem to be a few colors he's cycling through. Six by my count, starting with red. The camera is getting a bit blown out so it's hard to tell which ones they are, but this seems right, since he goes through them a few times.
- He cycles the colors by holding down the button. If you watch, at the start he is careful about only pressing the button for a short time, to keep the color being displayed from jumping ahead.

So it looks like he has a small list of RGB values and is cycling through them as the button is held, with a small amount of time for each one to display. We can discuss improvements to his implementation - but after you get your version working.
 

MPep

Senior Member
Doesn't look too bad.
Out of the 8 variations that are possible, he is only showing 6.

To me it looks like C1 (colour1), then C1+C2, C2, C2+C3, C3, C3+C1, repeat. The other options would have been C1+C2+C3, and all OFF.
 

Goeytex

Senior Member
Here is some code to try. RGB connect to C.1,c,2, & C.4. Make sure you have current limit resistors on the LED and a pull down resistor on the Pin C.3 (Button Switch)

Code:
[color=Green]'**************************
'**** 08M2 RGB LED DEMO ***
'**************************[/color]
[color=Blue]EEPROM [/color][color=Navy]0[/color][color=Black],[/color][color=Blue]([/color][color=Navy]%00000010[/color][color=Black],[/color][color=Navy]%00000100[/color][color=Black],[/color][color=Navy]%00010000[/color][color=Black],[/color][color=Navy]%00000110[/color][color=Black],[/color][color=Navy]%00010010[/color][color=Black],[/color][color=Navy]%00010100[/color][color=Black],[/color][color=Navy]%00010110[/color][color=Black],[/color][color=Navy]%00000000[/color][color=Blue])

Symbol [/color][color=Purple]Button1   [/color][color=DarkCyan]= [/color][color=Purple]PinC.3[/color]
[color=Blue]symbol [/color][color=Purple]Location [/color][color=DarkCyan]= [/color][color=Purple]b0
dirsC [/color][color=DarkCyan]= [/color][color=Navy]%00010110  [/color][color=Green]'set c.1,c.2,c.4 as outputs[/color]
[color=Purple]location [/color][color=DarkCyan]= [/color][color=Navy]0[/color]

[color=Black]MAIN:[/color]
[color=Blue]do 
    if [/color][color=Purple]button1 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then [/color][color=Black]change_color [/color][color=Green]' Wait for switch press[/color]
[color=Blue]loop[/color]

[color=Black]change_color:[/color]
[color=Blue]pause [/color][color=Navy]50[/color]
[color=Blue]do loop while [/color][color=Purple]button1 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Green]' wait for switch release  [/color]
[color=Blue]Read [/color][color=Purple]location[/color][color=Black],[/color][color=Purple]b1
pinsC [/color][color=DarkCyan]= [/color][color=Purple]b1[/color]
[color=Blue]inc [/color][color=Purple]location[/color]
[color=Blue]if [/color][color=Purple]location [/color][color=DarkCyan]> [/color][color=Navy]7 [/color][color=Blue]then
   [/color][color=Purple]location [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]endif
goto [/color][color=Black]main[/color]
 

vladthegreat1

New Member
Thank you all for the input, I will plug this all in when i get home and test it out after work. I will let you know results
 

vladthegreat1

New Member
Goeytex, yesterday before Bed i tried the second code you posted which i cant find for some reason no more. But it would not light the leds for some reason. But you probably already know that :)

so will this current code you have retain memory or once power is off the unit it will just start back at the first sequence?
 

Goeytex

Senior Member
It seems that several posts have disappeared. Forget the last code I posted. EEPROM will be retained with the original code I posted. Power off/on to verify.

However, once the EEPROM has been programmed as in the original code, you can then optionally add the #no_data directive to speed up further program downloads without overwriting the Data in EEPROM.
 
Top