![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi All, I would like to make a flickering candle with leds. I have seen these but I want to use some rgb leds I have so I can control the colours remotely. Initially of course the led candle will be flickering yellow and orange but I bought a 5 function remote control from Ebay and I want to use this to control the different colours... eg maybe red/pink... blue/purple..different shades of green.. If anybody has the code, and maybe the schematic, just to control the yellow/orange, that would be great to start. Any help with the code and schematic for the other effects would be appreciated. Thanks. Greg. | |
| |
| | #2 |
|
All the bits you need to make this happen are on the web. Mondo Technology - Pic Projects has a candle simulator. To make an RGB candle simulator you need to output a PWN signal for each color. The IR remote reciever has been done many times. Nigel has a good tutorial for doing one in assembler. Others have done it in C.
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) | |
| |
| | #3 |
|
Thanks 3vo, I will get to this soon. It looks like what i'm after. I would still like to use the rgb led idea so if anyone else has those details, that would be appreciated. | |
| |
| | #4 |
|
Thanks again 3v0 for the link but unfortunately the code comes back from my winpic programmer with errors. I presume that would be because i'm using a 16f84a instead of the original 12f675. Can anyone help me with the alterations needed to get this to work on my pic. Here is the hex.. :020000000528D1 :1000080009008316003085007F3090008312271482 :100018007F30A400A5002408A6001E203B20073935 :10002800031D1A282E20A400003CA5002508A600C0 :100038001E200F286430A2002608A000003CA10062 :1000480085160000A00B252885120000A10B292881 :10005800A20B20283B203F39A3003B203F39A307B0 :100068003B203F39A3073B203F39230708002708D7 :100078002807A8002907A9002A07AA002B07AB0010 :0E0088000310AB0D03182B142B08A70708005C :02400E00840F1D :02FFFE00750686 :00000001FF And here is the source code.. ; Candle Simulation ; 6/04 Luhan Monat ; ; Simulate flicker of candle using incandescent lamp ; device PIC12F675,intrc_osc,pwrte_on,wdt_off org 20h del1 ds 1 del2 ds 1 pcnt ds 1 temp ds 1 lev1 ds 1 lev2 ds 1 level ds 1 rbuf ds 5 LAMP = gp.5 org 0 goto start org 4 reti start bsf RP0 movlw 0 movwf GP movlw 127 movwf OSCCAL bcf RP0 bsf rbuf,0 ;seed random number movlw 127 movwf lev1 ;initial light level movwf lev2 ; Main Loop ; Create hi and low power levels ; Switch between levels candle movf lev1,w movwf level call power ;do lev1 power call rando andlw 7 btfss z goto :run ;skip 7 out of 8 call rmid ;generate new hi and low levels movwf lev1 sublw 0 movwf lev2 :run movf lev2,w ;do lev2 power movwf level call power goto candle ; PWM power control power movlw 100 ;set flicker rate: higher=slower movwf pcnt ;set loop count 1 movf level,w ;get target levelmovwf del1 ;set 1st delay sublw 0 movwf del2 ;set 2nd delay bsf LAMP ;power on 3 nopdecfsz del1 ;do 1st delay goto 3bcf LAMP ;power off 4 nopdecfsz del2 ;second delay goto 4decfsz pcnt goto 1 ; find sum of 4 random numbers ; skews results around 127 rmid call rando andlw 3fh movwf temp call rando andlw 3fh addwf temp call rando andlw 3fh addwf temp call rando andlw 3fh addwf temp,w ret ; Pseudo Rando Number ; "Chop Suey Machine" rando movf rbuf,w addwf rbuf+1,w movwf rbuf+1 addwf rbuf+2,w movwf rbuf+2 addwf rbuf+3,w movwf rbuf+3 addwf rbuf+4,w movwf rbuf+4 bcf c rlf rbuf+4 btfsc c bsf rbuf+4,0 movf rbuf+4,w addwf rbuf ret end QED Thanks in advance.... Greg. | |
| |
| | #5 |
|
Greg, 1st: When you post code always use code tags to keep formating correct. It is the # icon and generates tags like [CODE][/CODE]. You place your code between them. 2nd: If you want errors fixed you have to tell them what they are. The crystal ball routine was old a long time ago. 3rd: I would use a modern PIC with an internal osc like the 16F88 or 18F1320. It is also about half the price. 4th: I do not program in assembly. Some here do and they can help you if you want. There is no reason this code needs to be written in asm and since you want to modify it anyway you may as well start with c or basic. 5th: If you do not know how to program in any language this is over your head. We all started by blinking a single LED. 3v0
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) Last edited by 3v0; 3rd March 2009 at 02:02 PM. | |
| |
|
| Tags |
| 16f84a., candle, led, rgb |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| And you though the candle and nail hoax was bad! | Andy1845c | Chit-Chat | 62 | 25th November 2007 10:41 PM |
| LED Candle, help! Does this circuit work? | HarveyH42 | Electronic Projects Design/Ideas/Reviews | 6 | 24th April 2006 10:16 AM |
| Candle circuit needed... | captainkirksdog | General Electronics Chat | 14 | 20th February 2005 04:17 AM |
| Candle Light | Dudeler | General Electronics Chat | 2 | 29th April 2004 07:13 PM |
| Way to Light A candle | yojo77 | General Electronics Chat | 10 | 23rd December 2003 03:30 AM |