Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using TIMER in swordfish basic

Status
Not open for further replies.

MrDEB

Well-Known Member
attempting to sequentially turn on the letters R, Y, D, E, R, W, O, D at 1-2 second interval between letters.
Wanting to avoid using DELAYMS(XXXX) AS IT SCREWS UP THE program. My iterpation is each interval it adds to x. Hoping to use for the delay between letters
Sub OnTimer() X = X - 10 End Sub // initialise the timer module... Timer.Initialize(2) // initialise each timer - refresh is every 1000Hz (1ms)... Timer.Items(Timer1).Interval = 10000 // 100ms Timer.Items(Timer1).OnTimer = @OnTimer // timer event handler Timer.Items(Timer1).Interval = 20000 // 2000ms, no event handler // enable the timers... Timer.Items(Timer1).Enabled = true X = 10000 // main program loop... While true Timer.Start For X = 0 To 90000 If X >= 9000 Then //6000 is 5 seconds? R = 1 EndIf If X >= 8000 Then Y = 1 EndIf If X >= 7000 Then D = 1 EndIf If X >= 6000 Then E = 1 EndIf If X >= 5000 Then R_1 = 1 EndIf If X >= 4000 Then W = 1 EndIf If X >= 3000 Then O = 1 EndIf If X >= 2000 Then D_1 = 1 EndIf Next If X <= 1000 Then X = 100000// reset to 100000 End If Timer.Items(Timer2).Enabled = true // background flash LED... Head_light = 1 DelayMS(500) Head_light = 0 DelayMS(500)
 
Try this...
Every 1000ms (1sec) the OnTimer1 event is called which turns on the next LED in the sequence.
After 12 steps it turns them all off and starts over.

The time between LED steps is determined by the TIMER1 interval setting (in msecs):
Timer.Items(TIMER1).Interval = 1000

Code:
device = 18F2221
clock = 8

include "intosc.bas"   
#option DIGITALIO_INIT = true
include "setdigitalio.bas"

//12 VOLT LED STRIPS
dim R    as PORTA.0     // channel_1
dim Y    as PORTA.1     // channel_2
dim D    as PORTA.2     // channel_3
dim E    as PORTA.3     // channel_4
dim R_1  as PORTA.4     // channel_5
dim W    as PORTA.5     // channel_6
dim O    as PORTA.6     // channel_8
dim D_1  as PORTA.7     // channel_7

//HEADLIGHT ON TRAIN ENGINE
dim HEAD_LIGHT as PORTC.7   // HEAD LIGHT

// isr timer module
// default is TMR1, 1ms refresh interval
include "isrtimer.bas"
const TIMER1 = 0

dim led_step as byte

// timer 1 event handler
// this routine will be called every timer1 Interval
sub OnTimer1()
    led_step = led_step + 1
    select (led_step)
        case 1: R = 1
        case 2: Y = 1
        case 3: D = 1
        case 4: E = 1
        case 5: R_1 = 1
        case 6: W = 1
        case 7: O = 1
        case 8: D_1 = 1
        case >12:  // turn them all off
            R = 0
            Y = 0
            D = 0
            E = 0
            R_1 = 0
            W = 0
            O = 0
            D_1 = 0
            // start over next time
            led_step = 0
    end select      
end sub

// set all IO pins to output low
sub InitIO()
    // before enabling the outputs, init all LAT registers low
    LATA = 0
    LATB = 0
    LATC = 0
    
    // enable outputs
    TRISA = 0
    TRISB = 0
    TRISC = 0
end sub

main:
InitIO()
led_step = 0

// initialise the timer module for 1 timer...
Timer.Initialize(1)

// initialise each timer - refresh is every 1ms
Timer.Items(TIMER1).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER1).OnTimer = @OnTimer1   // timer event handler

 // enable the timers...
Timer.Items(TIMER1).Enabled = true

Timer.Start()

while true
    // flash LED...
    HEAD_LIGHT = 1
    DelayMS(500)
    HEAD_LIGHT = 0
    DelayMS(500)
end while
 
AHH! timer. interval is msecs
never occurred it was msecs
Will run suggested.
Was planning on starting over with a new slate and build from there. Been trying different senecrnos such as counting the number of TICKS (calling ontimer)
Thanks
 
suggested code works well
I looked over your suggestion and see some of my mistakes.
I need to tweek it with minor changes (I have the "O" in wrong order for one. and fiddle with the headlight section, add the red strips and the candle flames.
Thanks again
 
ADDED THE SPRINKLES, RED STRIPS BUT THE input ON b.1 is not connected. I need to figure it out why it is acting
Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2023 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 1/20/2023                                                      *
*  Version : 1.0                                                            *
*  Notes   : NEED TO ADD RED STRIPS, CANDLE FLAMES ROUTINE AND SPRINKLES.                                                                *
*          :                                                                *
*****************************************************************************
}
 Device = 18F2221
Clock = 8

Include "intosc.bas"   
#option DIGITALIO_INIT = true
Include "setdigitalio.bas"

Dim Red_Candle_STRIPS As PORTB.0  //--------------------------------turn on mosfet Q10
Dim Flames_ENABLE As PORTB.1  //-------------------------------------------TOGGLE SWITCH PORT

//CAKE SPRINKLES CATHODES CONNECTED TO PORT PINS
Dim Row_4 As PORTB.2
Dim Row_3 As PORTB.3
Dim Row_2 As PORTB.4
Dim Row_1 As PORTB.5

//HEADLIGHT ON TRAIN ENGINE
Dim Head_light As PORTC.7

//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2

// SPRINKLES ANODES
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6



//12 VOLT LED STRIPS
Dim R    As PORTA.0     // channel_1
Dim Y    As PORTA.1     // channel_2
Dim D    As PORTA.2     // channel_3
Dim E    As PORTA.3     // channel_4
Dim R_1  As PORTA.4     // channel_5
Dim W    As PORTA.5     // channel_6
Dim O    As PORTA.7     // channel_8
Dim D_1  As PORTA.6    // channel_7



// isr timer module
// default is TMR1, 1ms refresh interval
Include "isrtimer.bas"
Const TIMER1 = 0

Dim led_step As Byte

// timer 1 event handler
// this routine will be called every timer1 Interval
Sub OnTimer1()
    led_step = led_step + 1
    Select (led_step)
        Case 1: R = 1
        Case 2: Y = 1
        Case 3: D = 1
        Case 4: E = 1
        Case 5: R_1 = 1
        Case 6: W = 1
        Case 7: O = 1
        Case 8: D_1 = 1
        Case >12:  // turn them all off
            R = 0
            Y = 0
            D = 0
            E = 0
            R_1 = 0
            W = 0
            O = 0
            D_1 = 0
            // start over next time
            led_step = 0
    End Select
   Red_Candle_STRIPS = 1     
End Sub

// set all IO pins to output low
Sub InitIO()
    // before enabling the outputs, init all LAT registers low
   // before enabling the outputs, init all LAT registers low
LATA = 0
LATB.0 = 0
LATB.1 = 1
LATB.2 = 0
LATB.3 = 0
LATB.4 = 0
LATB.5 = 0
LATB.6 = 0
LATB.7 = 0
LATC = 0


//ENABLE OUTPUTS  port A, B, C
TRISA = 0   
TRISB.0 = 0
TRISB.1 = 1    //input
TRISB.2 = 0
TRISB.3 = 0
TRISB.4 = 0
TRISB.5 = 0
TRISB.6 = 0
TRISB.7 = 0
TRISC = 0

End Sub


Sub Sprinkles()
     // CYCLE THROUGH ENABLING THE ANODES CONNECTED TO rows
     // LIGHT CANDLES
 
  //cake sprinlkes colums
             //all colums HIGH
             RED = 1
             WHITE = 1
             BLUE = 1
             GREEN = 1
            
            Row_1 = 0   //led 1 is ON
            DelayMS(25)//enough to see ON?
            Toggle(RED) // turn off RED colum
            Toggle(Row_1) //turn OFF  row_1
            
                Row_2 = 0
                DelayMS(25)//enough to see ON?
                Toggle(WHITE)
                Toggle(Row_2)//turn OFF  row_2
                
                    Row_3 = 0
                    DelayMS(25)//enough to see ON?
                    Toggle(BLUE)
                    Toggle(Row_3)//turn OFF  row_3
                        
                       Row_4 = 0
                       DelayMS(25)//enough to see ON?
                       Toggle(GREEN)
                       Toggle(Row_4)//turn OFF  row_4
  End Sub
INPUT(FLAMES_ENABLE) 
 
main:
InitIO()
led_step = 0

// initialise the timer module for 1 timer...
Timer.Initialize(1)

// initialise each timer - refresh is every 1ms
Timer.Items(TIMER1).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER1).OnTimer = @OnTimer1   // timer event handler

 // enable the timers...
Timer.Items(TIMER1).Enabled = true

Timer.Start()

While true
    // flash LED...
    Head_light = 1
    DelayMS(500)
    Head_light = 0
    DelayMS(500)
    
If Flames_ENABLE = 0 Then
 Flame1 =1 // TURN ON CANDLE FLAMES
 Flame2 = 1
Flame3 = 1
 End If
Sprinkles() //TURN ON CAKE SPRINKLES
End While
;like the b.1 = 0
 
I attempted to add a second timer with limited success The sprinkles fail to (thinking not enough ON time.
Question in post #2 CASE>12:
what does the two dots (can't think what they are called?) do
Code:
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2023 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 1/21/2023                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2023 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 1/20/2023                                                      *
*  Version : 1.0                                                            *
*  Notes   :                                                                *
*          :                                                                *
*****************************************************************************
}
{
*****************************************************************************
*  Name    : UNTITLED.BAS                                                   *
*  Author  : [select VIEW...EDITOR OPTIONS]                                 *
*  Notice  : Copyright (c) 2023 [select VIEW...EDITOR OPTIONS]              *
*          : All Rights Reserved                                            *
*  Date    : 1/20/2023                                                      *
*  Version : 1.0                                                            *
*  Notes   : NEED TO ADD RED STRIPS, CANDLE FLAMES ROUTINE AND SPRINKLES.                                                                *
*          :                                                                *
*****************************************************************************
}
 Device = 18F2221
Clock = 8

Include "intosc.bas"   
#option DIGITALIO_INIT = true
Include "setdigitalio.bas"

Dim Red_Candle_STRIPS As PORTB.0  //--------------------------------turn on mosfet Q10
Dim Flames_ENABLE As PORTB.1  //-------------------------------------------TOGGLE SWITCH PORT

//CAKE SPRINKLES CATHODES CONNECTED TO PORT PINS
Dim Row_4 As PORTB.2
Dim Row_3 As PORTB.3
Dim Row_2 As PORTB.4
Dim Row_1 As PORTB.5

//HEADLIGHT ON TRAIN ENGINE
Dim Head_light As PORTC.7

//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2

// SPRINKLES ANODES
Dim RED As PORTC.3
Dim WHITE As PORTC.4
Dim BLUE As PORTC.5
Dim GREEN As PORTC.6



//12 VOLT LED STRIPS
Dim R    As PORTA.0     // channel_1
Dim Y    As PORTA.1     // channel_2
Dim D    As PORTA.2     // channel_3
Dim E    As PORTA.3     // channel_4
Dim R_1  As PORTA.4     // channel_5
Dim W    As PORTA.5     // channel_6
Dim O    As PORTA.7     // channel_8
Dim D_1  As PORTA.6    // channel_7



// isr timer module
// default is TMR1, 1ms refresh interval
Include "isrtimer.bas"
Const TIMER1 = 0
Const Timer2 = 1

Dim led_step As Byte
Dim Sprinkles As Byte


// timer 1 event handler
// this routine will be called every timer1 Interval
Sub OnTimer1() //FIRST TIMER
    led_step = led_step + 1
    Select (led_step)
        Case 1: R = 1
        Case 2: Y = 1
        Case 3: D = 1
        Case 4: E = 1
        Case 5: R_1 = 1
        Case 6: W = 1
        Case 7: O = 1
        Case 8: D_1 = 1
        Case >12:  // turn them all off
            R = 0
            Y = 0
            D = 0
            E = 0
            R_1 = 0
            W = 0
            O = 0
            D_1 = 0
            // start over next time
            led_step = 0
    End Select     
End Sub

Sub OnTimer2()  //SECOND TIMER
    Sprinkles = Sprinkles + 1
    Select (Sprinkles)
        Case 1: Row_1=0
        Case 2: Row_2=0 Toggle(Row_1)//ROW2 IS ON ROW1 IS OFF
        Case 3: Row_3=0 Toggle(Row_2)//OFF
        Case 4: Row_4=0 Toggle(Row_3)
        Case 5: Row_1=0 Toggle(Row_4)
        Case 6: Row_2=0 Toggle(Row_1)
        Case 7: Row_3=0 Toggle(Row_2)
        Case 8: Row_4=0 Toggle(Row_3)
         Case >12:
       Sprinkles = 0
    End Select     
End Sub

// set all IO pins to output low
Sub InitIO()
    // before enabling the outputs, init all LAT registers low
    LATA = 0
    LATB = 0
    LATC = 0
    
    // enable outputs
    TRISA = 0
    TRISB = 0
    TRISC = 0
End Sub
RED =1
WHITE = 1
BLUE = 1
GREEN = 1
main:
InitIO()// set inout/outputs
led_step = 0
Sprinkles = 0
// initialise the timer module for 1 timer...
Timer.Initialize(1)
Timer.Initialize(2)
// initialise each timer - refresh is every 1ms
Timer.Items(TIMER1).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER1).OnTimer = @OnTimer1   // timer event handler
Timer.Items(Timer2).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(Timer2).OnTimer = @OnTimer2   // timer event handler
 // enable the timers...
Timer.Items(TIMER1).Enabled = true
Timer.Items(Timer2).Enabled = true
Timer.Start()

While true
    // flash LED...
    Head_light = 1
    DelayMS(500)
    Head_light = 0
    DelayMS(500)
End While
 
The colon char (':') is used to separate the 'case' from the code statements

Code:
device = 18F2221
clock = 8

include "intosc.bas"  
#option DIGITALIO_INIT = true
include "setdigitalio.bas"

//12 VOLT LED STRIPS
dim R    as PORTA.0     // channel_1
dim Y    as PORTA.1     // channel_2
dim D    as PORTA.2     // channel_3
dim E    as PORTA.3     // channel_4
dim R_1  as PORTA.4     // channel_5
dim W    as PORTA.5     // channel_6
dim O    as PORTA.7     // channel_8
dim D_1  as PORTA.6     // channel_7

Dim Red_Candle_STRIPS As PORTB.0    // turn on mosfet Q10
Dim Flames_ENABLE As PORTB.1        // TOGGLE SWITCH PORT, input with external pullup

//CAKE SPRINKLES CATHODES CONNECTED TO PORT PINS
Dim Row_4 As PORTB.2
Dim Row_3 As PORTB.3
Dim Row_2 As PORTB.4
Dim Row_1 As PORTB.5

//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2

// SPRINKLES ANODES
Dim RED     As PORTC.3
Dim WHITE   As PORTC.4
Dim BLUE    As PORTC.5
Dim GREEN   As PORTC.6

//HEADLIGHT ON TRAIN ENGINE
dim HEAD_LIGHT as PORTC.7   // HEAD LIGHT

// isr timer module
// default is TMR1, 1ms refresh interval
include "isrtimer.bas"
const TIMER1 = 0
const TIMER2 = 1

dim led_step as byte
Dim Sprinkles As Byte

// timer 1 event handler
// this routine will be called every timer1 Interval
sub OnTimer1()
    led_step = led_step + 1
    select (led_step)
        case 1: R = 1
        case 2: Y = 1
        case 3: D = 1
        case 4: E = 1
        case 5: R_1 = 1
        case 6: W = 1
        case 7: O = 1
        case 8: D_1 = 1
        case >12:  // turn them all off
            R = 0
            Y = 0
            D = 0
            E = 0
            R_1 = 0
            W = 0
            O = 0
            D_1 = 0
            // start over next time
            led_step = 0
    end select     
end sub

Sub OnTimer2()  //SECOND TIMER
    Sprinkles = Sprinkles + 1
    Select (Sprinkles)
        Case 1: Row_4=1 Row_1=0     // turn off previous, turn on next
        Case 2: Row_1=1 Row_2=0
        Case 3: Row_2=1 Row_3=0
        Case 4: Row_3=1 Row_4=0
        Case 5: Row_4=1 Row_1=0
        Case 6: Row_1=1 Row_2=0
        Case 7: Row_2=1 Row_3=0
        Case 8: Row_3=1 Row_4=0
        Case 9: Row_4=1
        Case >12:
            Sprinkles = 0
    End Select    
End Sub

// set all IO pin directions and initial settings
sub InitIO()
    // before enabling the outputs, init all LAT registers low
    LATA = 0
    LATB = 0
    LATC = 0
   
    RED = 1
    WHITE = 1
    BLUE = 1
    GREEN = 1

    Row_1 = 1
    Row_2 = 1
    Row_3 = 1
    Row_4 = 1
 
    // enable outputs, except for PORTB.1
    TRISA = 0
    TRISB = 0
    TRISC = 0
    input(Flames_ENABLE)
end sub

main:
InitIO()
led_step = 0
Sprinkles = 0

// initialise the timer module for 2 timers...
Timer.Initialize(2)

// initialise each timer - refresh is every 1ms
Timer.Items(TIMER1).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER1).OnTimer = @OnTimer1   // timer event handler

Timer.Items(TIMER2).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER2).OnTimer = @OnTimer2   // timer event handler

 // enable the timers...
Timer.Items(TIMER1).Enabled = true
Timer.Items(TIMER2).Enabled = true

Timer.Start()

while true
    // flash LED...
    HEAD_LIGHT = 1
    DelayMS(500)
    HEAD_LIGHT = 0
    DelayMS(500)
end while
 
I RAN THE CODE IN POST#8 and it works just fine.
I was trying to find out why the code I posted in post#7 and found it had slight differences. I know I added timer2 etc and realized I failed to save before compiling. No wonder it didn't work.
I discovered that I know I changed the headlight from 500 to 200. compared both and discovered this.
small editing errors makes me feel foolish at best.
Thanks
 
Maybe I ran wrong code?
I need to figure out why the flames enable doesn't work right plus the E and red strips have a bad connection (have had issues with the male/female plugs.
 
Back in post #5 you had the 'input(Flames_ENABLE)' statement in the wrong place and it was getting set back to an output in initIO()


Try this:
Code:
device = 18F2221
clock = 8

include "intosc.bas"   
#option DIGITALIO_INIT = true
include "setdigitalio.bas"

//12 VOLT LED STRIPS
dim R    as PORTA.0     // channel_1
dim Y    as PORTA.1     // channel_2
dim D    as PORTA.2     // channel_3
dim E    as PORTA.3     // channel_4
dim R_1  as PORTA.4     // channel_5
dim W    as PORTA.5     // channel_6
dim O    as PORTA.7     // channel_8
dim D_1  as PORTA.6     // channel_7

Dim Red_Candle_STRIPS As PORTB.0    // turn on mosfet Q10
Dim Flames_ENABLE As PORTB.1        // TOGGLE SWITCH PORT, input with external pullup

//CAKE SPRINKLES CATHODES CONNECTED TO PORT PINS
Dim Row_4 As PORTB.2
Dim Row_3 As PORTB.3
Dim Row_2 As PORTB.4
Dim Row_1 As PORTB.5

//CANDLE FLAMES
Dim Flame1 As PORTC.0
Dim Flame2 As PORTC.1
Dim Flame3 As PORTC.2

// SPRINKLES ANODES
Dim RED     As PORTC.3
Dim WHITE   As PORTC.4
Dim BLUE    As PORTC.5
Dim GREEN   As PORTC.6

//HEADLIGHT ON TRAIN ENGINE
dim HEAD_LIGHT as PORTC.7   // HEAD LIGHT

// isr timer module
// default is TMR1, 1ms refresh interval
include "isrtimer.bas"
const TIMER1 = 0
const TIMER2 = 1

dim led_step as byte
Dim Sprinkles As Byte

// timer 1 event handler
// this routine will be called every timer1 Interval
sub OnTimer1()
    led_step = led_step + 1
    select (led_step)
        case 1: R = 1
        case 2: Y = 1
        case 3: D = 1
        case 4: E = 1
        case 5: R_1 = 1
        case 6: W = 1
        case 7: O = 1
        case 8: D_1 = 1
        case >12:  // turn them all off
            R = 0
            Y = 0
            D = 0
            E = 0
            R_1 = 0
            W = 0
            O = 0
            D_1 = 0
            // start over next time
            led_step = 0
    end select      
end sub

Sub OnTimer2()  //SECOND TIMER
    Sprinkles = Sprinkles + 1
    Select (Sprinkles)
        Case 1: Row_4=1 Row_1=0     // turn off previous, turn on next
        Case 2: Row_1=1 Row_2=0
        Case 3: Row_2=1 Row_3=0
        Case 4: Row_3=1 Row_4=0
        Case 5: Row_4=1 Row_1=0
        Case 6: Row_1=1 Row_2=0
        Case 7: Row_2=1 Row_3=0
        Case 8: Row_3=1 Row_4=0
        Case 9: Row_4=1
        Case >12:
            Sprinkles = 0
    End Select     
End Sub

// set all IO pin directions and initial settings
sub InitIO()
    // before enabling the outputs, init all LAT registers low
    LATA = 0
    LATB = 0
    LATC = 0
    
    // set specific output states
    RED = 1
    WHITE = 1
    BLUE = 1
    GREEN = 1

    Row_1 = 1
    Row_2 = 1
    Row_3 = 1
    Row_4 = 1
 
    Flame1 = 0
    Flame2 = 0
    Flame3 = 0
 
    // enable outputs, except for PORTB.1
    TRISA = 0
    TRISB = 0
    TRISC = 0
    input(Flames_ENABLE)
end sub

main:
InitIO()
led_step = 0
Sprinkles = 0

// initialise the timer module for 2 timers...
Timer.Initialize(2)

// initialise each timer - refresh is every 1ms
Timer.Items(TIMER1).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER1).OnTimer = @OnTimer1   // timer event handler

Timer.Items(TIMER2).Interval = 1000       // 1000 x 1ms = 1 sec
Timer.Items(TIMER2).OnTimer = @OnTimer2   // timer event handler

 // enable the timers...
Timer.Items(TIMER1).Enabled = true
Timer.Items(TIMER2).Enabled = true

Timer.Start()

while true
    // flash LED...
    HEAD_LIGHT = 1
    delayms(500)
    HEAD_LIGHT = 0
    delayms(500)
    if (Flames_ENABLE = 0) then
        Flame1 = 1  // turn on candle flames
        Flame2 = 1
        Flame3 = 1
    else
        Flame1 = 0  // turn off candle flames
        Flame2 = 0
        Flame3 = 0
    endif
end while
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top