... and this is another demo...
Code:
/*
* my 1st demo
*/
if (true) {
// the light is off
my_switch_1 = false;
// left?
if (Data2 > HT && Data3 < HT ) {
if (Data2 > HT ) {
my_led_left = true;
my_led_right = false;
left = true;
right = false;
start = false;
end = false;
myCount++;
printf("\r LEFT my_led_left: %d my_led_right: %d left: %d right: %d myCount: %d\r\n", my_led_left, my_led_right, left, right, myCount);
// turn on the leds
if (left ) {
// turn on the yellow led
// turn off the white led
}
}
}
// right
if (Data3 > HT && Data3 > HT) {
if (Data2 < HT ) {
my_led_left = false;
my_led_right = true;
left = false;
right = true;
start = false;
end = false;
myCount++;
printf("\r RIGHT my_led_left: %d my_led_right: %d left: %d right: %d myCount: %d\r\n", my_led_left, my_led_right, left, right, myCount);
if (right) {
// turn on the white led
// turn off thw yellow led
// break;
}
}
}
// end of my 1st demo
}
This is one rather works, however, there is a problem between switching the leds, for example, for example the idea is to if the "left" repeats twice than for example the light should go off, same idea for the right concept. I am thinking to use the state machine, like enumerator... to follow this. What do you think, so far, the off was not implemented, not really sure how to go about. Any ideas?
Best.