User manual

17
The example programme is very similar to the programme from the last section because of the
output to the digital outputs and the PWM-output. The first line has the command to convert an
analogue value, however.
Address
Command
Data
Comment
2A
6
9
A = AD1
2B
5
4
Port = A
2C
5
9
PWM = A
2D
2
6
Wait for 100 ms
2E
3
4
Jump –4
Listing 3: AD converter and PWM output
Test the programme with different sensor light exposure. The more light on the LDR, the lower
the voltage at AD1. Vice versa, darkness leads to maximum AD-values and thus maximum
brightness of the LED at the PWM output. Read the binary lines from the LED display and try to
adjust the brightness, e.g. to precisely half the range. The digital value then is at 0111 or 1000.
Flickering artificial lighting may cause the result to switch between two levels.
5 Random Generator
Use a jumper E3 against GND to start a basic programme for random generator. The button S1
is evaluated here. The associated input has an internal pull-up resistor that pulls the voltage to
VCC-level. The button is connected against ground. Pushing the button pulls the input S1 to
zero.