NXC - problem with 2 color sensors
Posted: 17 Oct 2010, 14:41
Hi all,
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 :
This works fine !
Now I wanted to do the same with 2 color sensors, one attached to port S2 and the other to port S3
New Code :
This doesn't work. The blue LED goes on and remains on.
Any idea anyone ?
Kind Regards,
Rudolf Lapie.
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.