Code: Select all
#define SHORT_WAIT 3 //short wait for value to stabilize
int A,B,C,E,AF,BF,CF,EF,Final; //global
task main()
{
SetUserDisplay (Final,0);
SetSensor (SENSOR_1, SENSOR_TOUCH);
Wait (100);
SetSensor(SENSOR_1, SENSOR_LIGHT); //power on sensor by making it light type
SetSensorType (SENSOR_2, SENSOR_TYPE_TOUCH);
while (true) //loop forever
{
if (SENSOR_1== 100)
{
SetSensor(SENSOR_1, SENSOR_TOUCH);
SetSensor(SENSOR_1, SENSOR_LIGHT);
Wait(SHORT_WAIT);
}
A = SENSOR_1*1; //read the A and scale by 1
SetSensor(SENSOR_1, SENSOR_TOUCH); //toggle power to change to channel 2
SetSensor(SENSOR_1, SENSOR_LIGHT);
Wait(SHORT_WAIT);
B = SENSOR_1*1; //read the B and scale by 1
SetSensor(SENSOR_1, SENSOR_TOUCH); //toggle power to change to channel 3
SetSensor(SENSOR_1, SENSOR_LIGHT);
Wait(SHORT_WAIT);
C = SENSOR_1*1; //read the C and scale by 1
SetSensor(SENSOR_1, SENSOR_TOUCH); //toggle power to change to channel 0
SetSensor(SENSOR_1, SENSOR_LIGHT);
if (A == 0) { AF = 0; }
else{ AF = 1; }
if (B == 0) { BF = 0; }
else { BF = 10; }
if (C == 0) { CF = 0; }
else{ CF = 100; }
EF = 1000;
Final = AF + BF + CF + EF;
}
}