Hi AvionicsMaster1
No big deal, someone on here reckons that mistakes are not mistakes but learning opportunities and I think he's right having had plenty of learning opportunities myself.
Still getting them.
Using your idea to copy and paste |OR Demon, thanks.
Thanyou to Richard for keeping us right and for introducing me to the lookup command which has led me onto writing my code in decimal and hex.
Having great fun with them, well this is a hobby and hobbies are supposed to be fun.
The following code is for a set of traffic lights on the roads as part of a 1/76 scale model railway.
Code:
'****************************************************************
'* Name : Four Way Traffic Lights *
'* Author : Jim Hagan *
'* Date : 10/07/2016 *
'* Version : 1.0 *
'* Notes : For 16F84A *
'****************************************************************
#CONFIG
__CONFIG _XT_OSC & _CP_OFF
#ENDCONFIG
'Defines
DEFINE OSC 4 'Tell PBP3 expected system clock frequency
'Aliases
LEDS1 var PORTB 'Assign name LEDS1 to PORTB
LEDS2 VAR PORTA 'Assign name LEDS2 to PORTA
'Variables
i var byte
'Initialize
TRISB = $0 'Set PORTB to Output
TRISA = $0
'Program Code
START
gosub REDGREEN
gosub REDAMBER
gosub GREENRED
gosub AMBERRED
goto START
REDGREEN
LEDS1 = $61 'LEDS 0, 5 and 6 on PORTB On
LEDS2 = $08 'LED 3 on PORTA On
pause 3000 'Puts lights on for 3 seconds
for i = 1 to 10
LEDS1 = $0
LEDS2 = $0
next i
return
REDAMBER
LEDS1 = $D3 'LEDS 0, 1, 4, 6 and 7 on PORTB On
LEDS2 = $04 'LED 2 on PORTA On
pause 2000 'Puts lights on for 2 seconds
for i = 1 to 10
LEDS1 = $0
LEDS2 = $0
next i
return
GREENRED
LEDS1 = $C 'LEDS 2 and 3 on PORTB On
LEDS2 = $03 'LEDS 0 and 1 on PORTA On
pause 3000
for i = 1 to 10
LEDS1 = $0
LEDS2 = $0
next i
return
AMBERRED
LEDS1 = $9A 'LEDS 1, 3, 4 and 7 on PORTB On
LEDS2 = $06 'LEDS 1 and 2 on PORTA On
pause 2000
for i = 1 to 10
LEDS1 = $0
LEDS2 = $0
next i
return
end
Regards
Jim
Bookmarks