Quick and dirty candle effect with PIC12F675
For best results use a clear amber LED, you can embbed the LED using a tube as cast and pouring molten parafin...
Code:
'****************************************************************
'* Name : RGB12F675 *
'* Author : Ivan Rosales, Guadalajara México *
'* Notice : Copyright (c) 2011 Ivan Rosales *
'* : All Rights Reserved *
'* Date : 31/08/2011 *
'* Version : 1.0 *
'* Notes : Efecto de Vela en Pin 5 (GP2) *
'* : Utilizar preferentemente LED Ambar *
'****************************************************************
@ Device PIC12F675,WDT_ON,PWRT_ON,PROTECT_OFF,MCLR_OFF,BOD_OFF
ansel=0 'No usar ADC's las entradas serán digitales
cmcon=7 'No usar comparadores analógicos
trisio=%001011 'GP2 Será salida
DEFINE OSCCAL_1K 1 'Auto-Calibración del reloj interno
'Definiciones
Vela var GPIO.2
Luz var byte
X var byte
Ciclos con 25
'Programa
Pral:
random luz
luz=luz//(255-ciclos)
if luz<120 then luz=luz+50
for x=1 to ciclos
pwm vela, luz+x, 1
next
goto pral
end
Re: Quick and dirty candle effect with PIC12F675
Thanks for your code example. It would be great if you could include a schematic. Because there is no shematic i cant put this in the User Projects section, but i have put the code example in the wiki here
Thank you for your contribution
Re: Quick and dirty candle effect with PIC12F675
The schematic could not be more simple ;)
As an alternative you can omit the switch and use an old USB cable to provide the the 5vdc (usually RED cable) and the Ground (usually BLACK cable) this way you can have a romantic companion for your computer...
Code:
5vdc (Vdd)
+ PIC12F675
| _/ ___
'--o/ o----o|° |o------------------.
-o| |o- Amber (Clear) |
-o| |o- LED |
-o|___|o------>|----------o
|
|
===
GND