Project description:
An LED is connected to one of the port pins of a PIC microcontroller. The
LED is flashed continuously with 1-s interval.
This project is so simple that any type of PIC microcontroller can be used.
As shown in Figure 5.1, a PIC16F84 type microcontroller is chosen for this project. Bit 0 of PORTB (RB0) is connected to a small LED through a current-limiting resistor. The voltage drop across an LED is approxi- mately 2 V. Assuming an LED current of 10 mA, the value of the resistor can be calculated as
R V I
5 2 0.3 K
10 mA
the nearest value is 330
LED is flashed continuously with 1-s interval.
This project is so simple that any type of PIC microcontroller can be used.
As shown in Figure 5.1, a PIC16F84 type microcontroller is chosen for this project. Bit 0 of PORTB (RB0) is connected to a small LED through a current-limiting resistor. The voltage drop across an LED is approxi- mately 2 V. Assuming an LED current of 10 mA, the value of the resistor can be calculated as
R V I
5 2 0.3 K
10 mA
the nearest value is 330
‘*************************************************************
‘
‘ LED FLASHING PROGRAM
‘ ======================
‘
‘ This program flashes an LED connected to port RB0 of PORTB. The
‘ Led is flashed with 1 second intervals.
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic
‘ File: LED1.BAS
‘
‘ Modifications
‘ ==========
‘
‘*************************************************************
‘
‘ SYMBOLS
‘
Symbol LED 0 ‘ Define RB0 as LED Symbol TRISB $86 ‘ TRISB address Symbol PORTB $06 ‘ PORTB address
‘
‘ START OF MAIN PROGRAM
‘
POKE TRISB, 0 ‘ Set PORTB pins as outputs
AGAIN:
HIGH LED ‘ Turn ON LED PAUSE 1000 ‘ Wait 1 second
LOW LED ‘ Turn OFF LED PAUSE 1000 ‘ Wait 1 second
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 with 1 second intervals.
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic
‘ File: LED1.BAS
‘
‘ Modifications
‘ ==========
‘
‘*************************************************************
‘
‘ SYMBOLS
‘
Symbol LED 0 ‘ Define RB0 as LED Symbol TRISB $86 ‘ TRISB address Symbol PORTB $06 ‘ PORTB address
‘
‘ START OF MAIN PROGRAM
‘
POKE TRISB, 0 ‘ Set PORTB pins as outputs
AGAIN:
HIGH LED ‘ Turn ON LED PAUSE 1000 ‘ Wait 1 second
LOW LED ‘ Turn OFF LED PAUSE 1000 ‘ Wait 1 second
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 with 1 second intervals.
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic Pro
‘ File: LED2.BAS
‘
‘ Modifications
‘ ==========
‘
‘*************************************************************
‘
‘ DEFINITIONS
‘
LED VAR PORTB.0 ‘ Define RB0 as LED
‘
‘ START OF MAIN PROGRAM
‘
TRISB 0 ‘ Set PORTB pins as outputs
AGAIN:
LED 1 ‘ Turn ON LED PAUSE 1000 ‘ Wait 1 second
LED 0 ‘ Turn OFF LED PAUSE 1000 ‘ Wait 1 second
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 with 1 second intervals.
‘
‘ Author: Dogan Ibrahim
‘ Date: October, 2005
‘ Compiler: PicBasic Pro
‘ File: LED2.BAS
‘
‘ Modifications
‘ ==========
‘
‘*************************************************************
‘
‘ DEFINITIONS
‘
LED VAR PORTB.0 ‘ Define RB0 as LED
‘
‘ START OF MAIN PROGRAM
‘
TRISB 0 ‘ Set PORTB pins as outputs
AGAIN:
LED 1 ‘ Turn ON LED PAUSE 1000 ‘ Wait 1 second
LED 0 ‘ Turn OFF LED PAUSE 1000 ‘ Wait 1 second
GOTO AGAIN ‘ Repeat
END ‘ End of program
Comments
Post a Comment