User manual
LPCXpresso Experiment Kit - User’s Guide
Page 56
Copyright 2013 © Embedded Artists AB
7.6.2 Lab 5b: Event Threshold
Another way to handle noise (varying values from an analog signal) is to introduce threshold handling.
In this exercise you shall implement a program that reports when the value of an analog signal has
changed more than a set limit. Create a program that prints the value of AIN0 in the console whenever
the change in value s large than 2% of the full scale.
Tip #1: 2% of 1024 steps equals 20,48, which can be rounded down to 20.
Tip #2: Remember the last reported value and compare the new sample against this value. If you
compare against the previous samples value then it is theoretically possible to slowly, slowly turn the
trimming potentiometer without getting any change report event.
As an extra experiment, create a program that reports changes as already implemented. However, if
no changes are detected, report the current value once every 5 seconds.
7.6.3 Lab 5c: Read Light Sensor
In this experiment a light sensor will provide the analog input value (instead of a trimming
potentiometer). The sensor, R24, can be found on schematic page 4, as illustrated in Figure 25 below.
The more light the sensor is exposed to, the lower the resistance becomes. Adjust the program code in
Lab 5a to read from AIN2 (instead of AIN0) and check what converted values to expect in different light
conditions.
What is the range of values between absolute dark and full sunlight? __________________________
Figure 25 – Light Sensor on Schematic Page 4