Woogle
- 2nd September 2009, 09:06
Hello,
Ok, I've been programming in Ass for a while, and now have seen the light.
Simple prog to flash an led if a button is pressed.
Code follow:
-----------------------------------------------------------------------------------------------------
@ DEVICE pic16F819
@ DEVICE INTRC_OSC_NOCLKOUT
@ DEVICE CPD_OFF
Define OSC 8 'Osciallator 8Mhz
OSCCON=112 'INT OSC 8 MHZ
ADCON0 = 0
CCP1CON = %00000000 'Turn comparators off
Trisa=%00000001 'Sets PortA RA0 and RA1 as ip rest as output.
CoolHeat Var PORTA.0 'Switch IP High=flash
RL1 Var PORTA.1 'Relay output
Start:
If CoolHeat=0 THen 'button not pressed
HIGH RL1
endif
If Coolheat=1 Then 'button pressed flashes LED
high rl1
pause 500
Low RL1
Pause 500
high rl1
pause 500
Low RL1
Pause 500
Endif
goto Start
end
-------------------------------------------------------------------------------------------------
The switch is pulled up via 4k7 to Vcc. LED has 330r in series.
When I power up the led is on as it should be, switch is open.
When I pull RA.0 high the led *should* flash but does not.
Any ideas?
Many thanks.
Ok, I've been programming in Ass for a while, and now have seen the light.
Simple prog to flash an led if a button is pressed.
Code follow:
-----------------------------------------------------------------------------------------------------
@ DEVICE pic16F819
@ DEVICE INTRC_OSC_NOCLKOUT
@ DEVICE CPD_OFF
Define OSC 8 'Osciallator 8Mhz
OSCCON=112 'INT OSC 8 MHZ
ADCON0 = 0
CCP1CON = %00000000 'Turn comparators off
Trisa=%00000001 'Sets PortA RA0 and RA1 as ip rest as output.
CoolHeat Var PORTA.0 'Switch IP High=flash
RL1 Var PORTA.1 'Relay output
Start:
If CoolHeat=0 THen 'button not pressed
HIGH RL1
endif
If Coolheat=1 Then 'button pressed flashes LED
high rl1
pause 500
Low RL1
Pause 500
high rl1
pause 500
Low RL1
Pause 500
Endif
goto Start
end
-------------------------------------------------------------------------------------------------
The switch is pulled up via 4k7 to Vcc. LED has 330r in series.
When I power up the led is on as it should be, switch is open.
When I pull RA.0 high the led *should* flash but does not.
Any ideas?
Many thanks.