be80be
Well-Known Member
How can I make the led stay on with the sw and stay off with the sw.
Here the code I started
thanks for any help
Here the code I started
Code:
Device = 18F1220
Clock = 8
Config OSC = INTIO2 // Use the Internal Oscillator
Include "utils.bas"
Dim sw As PORTB.3 // Assign an alias for the switch
Dim LED1 As PORTB.7 // Assign an alias for "LED"
Dim LED2 As PORTB.6
Dim LED3 As PORTB.5
Dim LED4 As PORTB.4
// Start Of Program...
OSCCON = %01111111 // Sets up the internal oscillator
SetAllDigital // Make all Pins digital I/O's
Low(LED1) // Make the LED pin an output and set it low
Low(LED2)
Low(LED3)
Low(LED4)
While sw = 1
wend
While true
Repeat
Until Sw = 1
LED1 = 1 // Turn on the LED
LED2 = 1
LED3 = 1
LED4 = 1
DelayMS(500) // Delay for half a second
LED1 = 0 // Turn off the LED
LED2 = 0
LED3 = 0
LED4 = 0 // Delay for half a second
DelayMS(500)
Wend
Last edited: