My team and I have been trying to create a wack-a-mole type game. So what we have done is have a button and a light next to each other and when light activates you press the button and you get a point( meaning another light activates). BUT we have ran into the problem that we can’t get the the light that keeps the score to light up when button and LED are on. We have four buttons and four lights and when a light goes on you press the corresponding button then you get a point then LED 5 (the light that keeps score) lights up for 2 seconds. (This is on RobotC.)
int value;
task main()
{
while(1==1)
{
value = rand() % 4 + 1;
if (value == 1)
{
turnLEDOn(GreenLED1);
waitInMilliseconds(600);
turnLEDOff(GreenLED1);
waitInMilliseconds(600);
}
if (value == 2)
{
turnLEDOn(GreenLED2);
waitInMilliseconds(600);
turnLEDOff(GreenLED2);
waitInMilliseconds(600);
}
if (value == 3)
{
turnLEDOn(GreenLED3);
waitInMilliseconds(600);
turnLEDOff(GreenLED3);
waitInMilliseconds(600);
}
if (value == 4)
{
turnLEDOn(GreenLED4);
waitInMilliseconds(600);
turnLEDOff(GreenLED4);
waitInMilliseconds(600);
}
if(SensorValue(GreenLED1)==true && SensorValue(Button1)==1)
{
turnLEDOn(GreenLED5);
waitInMilliseconds(2000);
turnLEDOff(GreenLED5);
}
}
}