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

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
Don’t worry if the LDR you use doesn’t look like the one used in the layout as LDRs come in all shapes
and sizes, but they all perform the same task. However, their light level resistance may vary. But again,
this doesn’t actually matter, as we’ll be detecting changes in light level, not the level itself .
The circuit for the LDR layout is shown below:
The program for the Light Level Detector is shown below. The code will activate the LED when the LDR
sees a certain level of darkness, just like a cockroach:
' Illuminate an LED when an LDR connected to AN0 sees darkness
'
' Altering the value within the If-Then condition will set the light level threshold
' Any value from 0 to 1023 is valid, however, larger values indicate darkness
'
'
' Open the ADC:
'
'
'
'
'
'
Crownhill AssociatesLimited 2009 - All Rights Reserved
Dim LDR_Value As Word
Symbol LED = RB0
Include
OpenADC(ADC_FOSC_32 & ADC_RIGHT_JUST & ADC_2_TAD, ADC_REF_VDD_VSS, ADC_1ANA)
While 1 = 1
Wend
LDR_Value = ReadADC(0)
If LDR_Value > 400 Then
Else
EndIf
DelayUS 30
High LED
Low LED
"ADC.inc"
Fosc set for Fosc / 32
Right justified for 10-bit operation
Tad value of 2
Vref+ at Vcc : Vref- at Gnd
Make AN0 an analogue input
Amicus18 Companion Shield
Version 1.0
AN4/AN5
AN3/RA3
AN2/RA2
AN1/RA1
AN0/RA0
PortA
Power
GND
GND
RA4
3V3
Rst
Vin
5V
' Holds the 10-bit ADC value from the LDR
' Pin where the LED is connected. i.e. bit-0 of PortB
' Load the ADC macros into the program
' Create an infinite loop
' Read the ADC value from AN0
' Is the ADC value above 400. i.e. getting darker
' Yes. So illuminate the LED
' Otherwise...
' Extinguish the LED
' Allow the ADC to recover
' Do it forever
LDR
10K
Ω
33
LED
47
Ω
PortB
Power
GND
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0
06-10-2009

Related parts for AMICUS18-COMPANION-SHIELD