1818281+1818282 Microchip Technology, 1818281+1818282 Datasheet - Page 34

no-image

1818281+1818282

Manufacturer Part Number
1818281+1818282
Description
EDF / AMICUS18 + SHIELD, BUNDLE
Manufacturer
Microchip Technology
Type
Development Boardr

Specifications of 1818281+1818282

Kit Contents
Board
Svhc
No SVHC (15-Dec-2010)
Kit Features
Nine 10-bit ADC Inputs, Two 10-bit PWM Outputs, Two Comparators
Mcu Supported Families
PIC18F25K20
Silicon Manufacturer
Microchip
Core Architecture
PIC
Core Sub-architecture
PIC18
Silicon Core Number
PIC18F
Silicon Family Name
PIC18FxxKxx
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 1818281+1818282