User manual

ASURO - 71
-
C for ASURO
9.2.12. unsigned char PollSwitch (void)
This function scans the position of switches (K1-K6) and returns one byte, containing information,
which switches have been activated. Switch 1 will set the  rst bit number 5, switch 2 will set the
second bit, ... switch 6 will set bit number 5,
Bit0 (1) -> K6
Bit1 (2) -> K5
Bit2 (4) -> K4
Bit3 (8) -> K3
Bit4 (16) -> K2
Bit5 (32) -> K1
Activating switches 1,3 and 5 will cause the function to return 42 (32+8+2 = 42).
To be sure, the function may be called several times in sequence to provide a “correct” answer.
Capacitor C7  rst must be discharged, which may take some time. If you scan the A/D-converter
prematurely, some unreliable data may be delivered.
Example:
unsigned char taste;
.
.
switch = PollSwitch();
if (switch>0) {MotorSpeed(0,0);}
Well, that’s it. Now it’s up to you to be creative.