I added a color sensor to my robot and just for fun I wanted it to alternate between blue, green, red.
[ I use BricxCC, version 3.3.8.8 of 29/06/2010 ]
The code :
Code: Select all
counter ++ ;
switch (counter)
{
case 1: SetSensorColorBlue(S3); break ;
case 2 : SetSensorColorRed(S3);break ;
case 3 : SetSensorColorGreen(S3); break ;
default : counter = 0 ; SetSensorColorNone (S3) ; break ;
}
Now I wanted to do the same with 2 color sensors, one attached to port S2 and the other to port S3
New Code :
Code: Select all
counter ++ ;
switch (counter)
{
case 1: SetSensorColorBlue(S2); SetSensorColorBlue(S3); break ;
case 2 : SetSensorColorRed(S2); SetSensorColorRed(S3); break ;
case 3 : SetSensorColorGreen(S2); SetSensorColorGreen(S3); break ;
default : counter = 0 ; SetSensorColorNone (S2) ; SetSensorColorNone (S3) ; break ;
}
Any idea anyone ?
Kind Regards,
Rudolf Lapie.