AMICUS18-COMPANION-SHIELD AMICUS, AMICUS18-COMPANION-SHIELD Datasheet - Page 24

Amicus18 Companion Shield

AMICUS18-COMPANION-SHIELD

Manufacturer Part Number
AMICUS18-COMPANION-SHIELD
Description
Amicus18 Companion Shield
Manufacturer
AMICUS

Specifications of AMICUS18-COMPANION-SHIELD

Silicon Manufacturer
Microchip
Core Architecture
PIC
Core Sub-architecture
PIC18
Features
USB Interface, In Circuit Serial Programming Interface
Kit Contents
Board
Silicon Family Name
PIC
Silicon Core Number
PIC18F25K20
Rohs Compliant
Yes
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With
PIC18F25K20 Microcontroller
Notice how the state of the pin is 0 when the button is pressed. This is because the weak pull-up resis-
tor (22K
ground when it’s operated.
Now that we know that the pin’s state is 0 when the button is operated, decisions can be made upon it.
The program below will flash the LED 10 times when the button is pressed:
' Demonstrate a switch input using a pull-up resistor
' Flash an LED based upon a button press
'
'------------------------------------
' Subroutine to flash the LED
FlashLED:
'------------------------------------
' Main program starts here
Main:
Crownhill AssociatesLimited 2009 - All Rights Reserved
Dim Flash As Byte
Symbol Switch = RB4
Symbol LED = RB0
GoTo Main
For Flash = 0 To 9
Next
Return
Input Switch
While 1 = 1
Wend
Ω
EndIf
) holds the pin to 3.3 Volts when it’s not being operated, and the button pulls the pin to
High LED
DelayMS 100
Low LED
DelayMS 100
If Switch = 0 Then
GoSub FlashLED
Amicus18 Companion Shield
Version 1.0
' Holds the amount of flashes
' Button is connected to RB4 (PortB.4)
' LED attached to RB0
' Jump over the subroutine
' Create a loop of 10 iterations
' Illuminate the LED
' Wait 100 milliseconds
' Extinguish the LED
' Wait 100 milliseconds
' Close the loop
' Exit the subroutine
' Make the button pin an input
' Create an infinite loop
' Is the button pressed ?
' Yes. So flash the LED
' Do it forever
23
06-10-2009

Related parts for AMICUS18-COMPANION-SHIELD