NXC - problem with 2 color sensors

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
rlapie
Posts: 1
Joined: 17 Oct 2010, 14:34

NXC - problem with 2 color sensors

Post 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.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC - problem with 2 color sensors

Post by mattallen37 »

Post the whole code.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC - problem with 2 color sensors

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
pbenco
Posts: 71
Joined: 29 Sep 2010, 09:43
Contact:

Re: NXC - problem with 2 color sensors

Post by pbenco »

Hello Rudolf

Perhaps have you forget to initialize the second color sensor?

Regards
pbenco
pbenco.wordpress.com/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC - problem with 2 color sensors

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests