1st post so please be gentle with me :lol:
Am learning as i go ,what i need is the pic (16f628a) to count to 63 at certain counts it branches off to light some leds, when i programme the pic (im using the velleman programmer/demo board) all that happens is led 6 lights up for a second or so and then goes out and there is no other activity, im posting the programme i came up with and would appreciate if someone could spare a few minutes to explain where ive gone wrong. I suspect its the if then section of the code or maybe the count code, im stumped although i suspect its because i didnt put loop: at the end of main
many thanks smeghead
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : Smegs Customs *
'* Notice : Copyright (c) 2008 Smegs Customs *
'* : All Rights Reserved *
'* Date : 11/2/2008 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
Z var word 'set up variable Z
main:
for Z = 1 to 63 'set count up
pause 100 'delay
next z 'increment count up
IF z < 50 THEN knight 'if count less than 50 knight sequence
if z > 50 then wash 'if count over 50 then wash
if z = 60 then random1 'if count =60 then random1
knight:
High 0 ' Turn on LED connected to PORTB.0
Pause 50 ' Delay for .5 seconds
Low 0 ' Turn off LED connected to PORTB.0
Pause 25 ' Delay for .5 seconds
High 1 ' Turn on LED connected to PORTB.1
Pause 25 ' Delay for .5 seconds
Low 1 ' Turn off LED connected to PORTB.1
Pause 25 ' Delay for .5 seconds
High 2 ' Turn on LED connected to PORTB.2
Pause 25 ' Delay for .5 seconds
Low 2 ' Turn off LED connected to PORTB.2
Pause 25 ' Delay for .5 seconds
High 3 ' Turn on LED connected to PORTB.3
Pause 25 ' Delay for .5 seconds
Low 3 ' Turn off LED connected to PORTB.3
Pause 25 ' Delay for .5 seconds
High 4 ' Turn on LED connected to PORTB.4
Pause 25 ' Delay for .5 seconds
Low 4 ' Turn off LED connected to PORTB.4
Pause 25 ' Delay for .5 seconds
High 5 ' Turn on LED connected to PORTB.5
Pause 25 ' Delay for .5 seconds
Low 5 ' Turn off LED connected to PORTB.5
Pause 25 ' Delay for .5 seconds
High 6 ' Turn on LED connected to PORTB.6
Pause 25 ' Delay for .5 seconds
Low 6 ' Turn off LED connected to PORTB.6
Pause 50 ' Delay for .5 seconds
High 5 ' Turn on LED connected to PORTB.5
Pause 25 ' Delay for .5 seconds
Low 5 ' Turn off LED connected to PORTB.5
Pause 25 ' Delay for .5 seconds
High 4 ' Turn on LED connected to PORTB.4
Pause 25 ' Delay for .5 seconds
Low 4 ' Turn off LED connected to PORTB.4
Pause 25 ' Delay for .5 seconds
High 3 ' Turn on LED connected to PORTB.3
Pause 25 ' Delay for .5 seconds
Low 3 ' Turn off LED connected to PORTB.3
Pause 25 ' Delay for .5 seconds
High 2 ' Turn on LED connected to PORTB.2
Pause 25 ' Delay for .5 seconds
Low 2 ' Turn off LED connected to PORTB.2
Pause 25 ' Delay for .5 seconds
High 1 ' Turn on LED connected to PORTB.1
Pause 25 ' Delay for .5 seconds
Low 1 ' Turn off LED connected to PORTB.1
Pause 25 ' Delay for .5 seconds
return ' go back to main loop
wash:
high 5 ' led 5 high
pause 1000 'pause
low 5 ' led 5 low
return ' go back to main loop
random1: 'flashing led bit
high 1:high 2:high 3:high 4:high 5 'too stupid to write a real random flashy thing
pause 25
low 1:low 2:low 3
pause 25
high 2:high 6: high0
pause 100
low 0:low 1: low 2: low 3:low 4:low 5:low 6
return 'back to main loop
[TabIndex]
Value=0
Bookmarks