George L.
New Member
Hello,
I have been working on programming a PIC 16F628A-I/P to blink two banks of LEDs in two different patterns.
I am using MikroBASIC for PIC to write the code and I program it with ICprog. The code is supposed to make the LED banks blink back and forth ten times and then do the same for the second pattern, but double flash each bank.
When I run this code with the circuit, it only runs though the first pattern and doesn't do the double blink pattern. I have been at it for 7 hours and really need some help.
Here is the code:
program LED_blinkz
Dim x as byte
Dim y as byte
TRISB.4 = 0
TRISB.3 = 0
x = 0
y = 0
Main: ;Start of pattern one
x = x+1
PORTB.4 = 1
Delay_MS(40)
PORTB.4 = 0
Delay_MS(150)
PORTB.3 = 1
Delay_MS(40)
PORTB.3 = 0
Delay_MS(150)
If x>10 then ; tells it do repeat 10 times
goto AUX
else
goto main
end if
AUX: ; start of second pattern (IT NEVER GETS HERE!!!!!!!!THIS IS THE PROBLEM)
y = y + 1
PORTB.4 = 1
Delay_MS(1000)
PORTB.4 = 0
Delay_MS(100)
PORTB.4 = 1
Delay_MS(1000)
PORTB.4 = 0
Delay_MS(200)
PORTB.3 = 1
Delay_MS(1000)
PORTB.3 = 0
Delay_MS(100)
PORTB.3 = 1
Delay_MS(1000)
PORTB.3 = 0
Delay_MS(100)
PORTB.3 = 1
Delay_MS(1000)
If y>10 then ; tells it to repeat 10 times
goto main
else
goto AUX
end if
End.
-------------------------
The 1st pattern is just repeated over and over, it never does the second pattern. I think there is something wrong with the way I am writing the If/then statements.
If anyone can help, please do.
thanks in advance,
George L.
I have been working on programming a PIC 16F628A-I/P to blink two banks of LEDs in two different patterns.
I am using MikroBASIC for PIC to write the code and I program it with ICprog. The code is supposed to make the LED banks blink back and forth ten times and then do the same for the second pattern, but double flash each bank.
When I run this code with the circuit, it only runs though the first pattern and doesn't do the double blink pattern. I have been at it for 7 hours and really need some help.
Here is the code:
program LED_blinkz
Dim x as byte
Dim y as byte
TRISB.4 = 0
TRISB.3 = 0
x = 0
y = 0
Main: ;Start of pattern one
x = x+1
PORTB.4 = 1
Delay_MS(40)
PORTB.4 = 0
Delay_MS(150)
PORTB.3 = 1
Delay_MS(40)
PORTB.3 = 0
Delay_MS(150)
If x>10 then ; tells it do repeat 10 times
goto AUX
else
goto main
end if
AUX: ; start of second pattern (IT NEVER GETS HERE!!!!!!!!THIS IS THE PROBLEM)
y = y + 1
PORTB.4 = 1
Delay_MS(1000)
PORTB.4 = 0
Delay_MS(100)
PORTB.4 = 1
Delay_MS(1000)
PORTB.4 = 0
Delay_MS(200)
PORTB.3 = 1
Delay_MS(1000)
PORTB.3 = 0
Delay_MS(100)
PORTB.3 = 1
Delay_MS(1000)
PORTB.3 = 0
Delay_MS(100)
PORTB.3 = 1
Delay_MS(1000)
If y>10 then ; tells it to repeat 10 times
goto main
else
goto AUX
end if
End.
-------------------------
The 1st pattern is just repeated over and over, it never does the second pattern. I think there is something wrong with the way I am writing the If/then statements.
If anyone can help, please do.
thanks in advance,
George L.