An LED is connected to one of the port pins of a PIC microcontroller. The
LED is flashed continuously as in the following sequence:
3 flashes with 250ms interval between each flash.
2 s delay.
3 flashes with 250ms interval between each flash.
‘********************************************************************
‘
‘ LED FLASHING PROGRAM
‘ ======================
‘
‘ This program flashes an LED connected to port RB0 of PORTB. The
‘ LED is flashed continuously as follows:
‘
‘ Flash 3 times with 250ms intervals
‘ Wait 2 seconds
‘ Flash 3 times with 250ms intervals
‘ .................................................
‘ .................................................
‘
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic
‘ File: LED3.BAS
‘
‘ Modifications
‘ ==========
‘
‘********************************************************************
‘
‘ SYMBOLS
‘
Symbol LED 0 ‘ Define RB0 as LED Symbol TRISB $86 ‘ TRISB address Symbol PORTB $06 ‘ PORTB address
‘
‘ VARIABLES
‘
Symbol Cnt B0 ‘ Declare Cnt as a byte
‘
‘ START OF MAIN PROGRAM
‘
AGAIN:
POKE TRISB, 0 ‘ Set PORTB pins as outputs
FOR Cnt 1 TO 3
HIGH LED ‘ Turn ON LED PAUSE 250 ‘ Wait 250ms LOW LED ‘ Turn OFF LED PAUSE 250 ‘ Wait 250ms
NEXT Cnt
PAUSE 2000 ‘ Wait 2 seconds
GOTO AGAIN ‘ Repeat
END ‘ End of program
‘********************************************************************
‘
‘ LED FLASHING PROGRAM
‘ ======================
‘
‘ This program flashes an LED connected to port RB0 of PORTB. The
‘ LED is flashed continuously as follows:
‘
‘ Flash 3 times with 250ms intervals
‘ Wait 2 seconds
‘ Flash 3 times with 250ms intervals
‘ .................................................
‘ .................................................
‘
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic Pro
‘ File: LED4.BAS
‘
‘ Modifications
‘ ==========
‘
‘********************************************************************
‘
‘
‘ DEFINITIONS
‘
Cnt VAR BYTE ‘ Declare Cnt as a byte
‘
‘ START OF MAIN PROGRAM
‘
TRISB 0 ‘ Set PORTB pins as outputs
AGAIN:
FOR Cnt 1 TO 3
PORTB.0 1 ‘ Turn ON LED PAUSE 250 ‘ Wait 250ms PORTB.0 0 ‘ Turn OFF LED PAUSE 250 ‘ Wait 250ms
NEXT Cnt
PAUSE 2000 ‘ Wait 2 seconds
GOTO AGAIN ‘ Repeat
END ‘ End of program
Comments
Post a Comment