I believe that I was not clear in the previous post.
Well, what I basically want is that the LED1, connected in PORTB.0, continue flashing even when a subroutine is called. That is when you get "wait 10 seconds" of the subroutine FlashLED2015 I want LED1 continues flashing.
Example:
chip 16f628A, 4
define LED1 PORTB.0
Dim LED1 OUT
define LED2 PORTB.1
Dim LED2 OUT
FlashLED:
Pulseout LED1, 150 ms
wait 150 ms
If PORTA.0 = on then gosub FlashLED2015
Goto FlashLED
Sub FlashLED2015
Pulseout LED2, 150 ms
wait 10 s ; My problem is here
End Sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anobium and David Stephenson,
Thank you for answers.
Well, I needed the time of 10s did not affect the LED1. Basically I wanted the two codes worked independently of each other.
It is possible?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Add extra conditionals, counter, etc. for a second LED.
#chip 16f1503,4
#define LED1 PortA.0
dir LED1 out
dim TenthSec as word
On Interrupt Timer1Overflow Call BlinkLED
InitTimer1 Osc, PS1_1/2
StartTimer 1
Set LED1 On
TenthSec = 0
LED_ON = True
Main:
If TenthSec = 30 Then
LED_ON = NOT LED_ON 'toggle led flag
Set TMR1ON OFF
IF LED_ON = True Then
Set LED1 ON
Else
Set LED1 OFF
End If
TenthSec = 0
TMR1H = 60
TMR1L = 175
Set TMR1ON ON
End if
goto main
Sub BlinkLED
TMR1IF = 0
TMR1H = 60
TMR1L = 175
TenthSec += 1
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys!!!
I need your help.
My problem is this, I need the LED blinks even I push the button.
I hope you understand me.
Sorry about my English.
See the code:
chip 16f628A, 4
Do
Wait 150 ms
if PORTA.0 = on then set PORTB.0 on
Wait 150 ms
set PORTB.0 off
gosub flash
Loop
sub flash
Set PORTB.1 on
wait 250 ms
Set PORTB.1 off
wait 250 ms
end sub
I believe that I was not clear in the previous post.
Well, what I basically want is that the LED1, connected in PORTB.0, continue flashing even when a subroutine is called. That is when you get "wait 10 seconds" of the subroutine FlashLED2015 I want LED1 continues flashing.
Example:
chip 16f628A, 4
define LED1 PORTB.0
Dim LED1 OUT
define LED2 PORTB.1
Dim LED2 OUT
FlashLED:
Pulseout LED1, 150 ms
wait 150 ms
If PORTA.0 = on then gosub FlashLED2015
Goto FlashLED
Sub FlashLED2015
Pulseout LED2, 150 ms
wait 10 s ; My problem is here
End Sub
Do you have the latest Hot Release of GCB? It has a lot of demonstrations of flashing an LED.
But, if all you want to do is flash an LED. Purchase a flashing LED and then just turn the Port On.
If you want to do the flashing in code then look at the Interrupt demos. They show how to flash an LED using an interrupt.
But, if you need more guidance do not hesitate to ask again. We can write some sample code based on the demos.
An easy way would be to replace the wait 10 sec with a flashing loop that takes 10 sec.
You also need to change dim to dir.
~~~~~~
define led1 portb.0
Dir LED1 OUT
define LED2 PORTB.1
Dir LED2 OUT
FlashLED:
Pulseout LED1, 150 ms
wait 150 ms
If PORTA.0 = on then gosub FlashLED2015
Goto FlashLED
Sub FlashLED2015
Pulseout LED2, 150 ms
repeat 33
pulseout led1, 150 ms
wait 150 ms
end repeat
End Sub
~~~~~~~~~~~
Anobium and David Stephenson,
Thank you for answers.
Well, I needed the time of 10s did not affect the LED1. Basically I wanted the two codes worked independently of each other.
It is possible?
Here is a program to blink an LED every 3 Sec or so. It uses an interrupt, and is therefore independent of what is going on in main. Setting up the 100ms time base for TMR1 overflow is explained by Hugh in this post here: https://sourceforge.net/p/gcbasic/discussion/579125/thread/03348d5c/#6c76/281f
Add extra conditionals, counter, etc. for a second LED.