Page 1 of 1

NXC - problem with 2 color sensors

Posted: 17 Oct 2010, 14:41
by rlapie
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 :

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 ;
           }
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 :

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 ;
           }
This doesn't work. The blue LED goes on and remains on.

Any idea anyone ?

Kind Regards,
Rudolf Lapie.

Re: NXC - problem with 2 color sensors

Posted: 17 Oct 2010, 15:17
by mattallen37
Post the whole code.

Re: NXC - problem with 2 color sensors

Posted: 18 Oct 2010, 05:15
by mightor
Rudolf,

Please post a small working program that demonstrates this issue. If it is a bug then it will be easier for John to hunt down.

- Xander

Re: NXC - problem with 2 color sensors

Posted: 21 Oct 2010, 08:01
by pbenco
Hello Rudolf

Perhaps have you forget to initialize the second color sensor?

Regards
pbenco

Re: NXC - problem with 2 color sensors

Posted: 21 Oct 2010, 13:52
by afanofosc
I will try to run some tests this weekend with two color sensors to see if I can replicate the OP's problem.

John Hansen