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

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
Light Level Switch (Moth Mode)
The same circuit and layout is used for the opposite reaction to light levels. The code below will illumi-
nate the LED when light levels increase, just like a moth to a flame.
' Illuminate an LED when an LDR connected to AN0 sees light
' Altering the value within the If-Then condition will set the dark level threshold
' Any value from 0 to 1023 is valid, however, smaller values indicate lightness
'
' Open the ADC:
'
'
'
'
'
The code is essentially the same as cockroach mode, except the LED illuminates when the ADC value is
less that 400, instead of greater than 400.
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
' 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 less than 400. i.e. getting lighter
' Yes. So illuminate the LED
' Otherwise...
' Extinguish the LED
' Allow the ADC to recover
' Do it forever
35
06-10-2009

Related parts for 1818281+1818282