Quick and dirty candle effect with PIC12F675
by
Published on - 1st September 2011 04:30
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: How to measure how long I pressed a button ?
What happens if more than one button is pressed at the same time?
HenrikOlsson Today, 17:16Anyway, this might serve as starting point. It compiles but it is not tested.
Long_Press CON 5000
Short_Press con 100
cnt...