|
Page 1 of 1
|
[ 8 posts ] |
|
| Author |
Message |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Redefining sensors.
I have a lego colour sensor and I need to use it as both a light and colour sensor in a program. Is this possible?Is it also possible to switch between the modes of the sensor during the program? I have tried but I cannot define sensors other than the beginning of the program.
|
| Sat Aug 04, 2012 12:32 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2859 Location: Rotterdam, The Netherlands
|
 Re: Redefining sensors.
Sure, that's very possible. SensorValue will adjust accordingly. In FULL mode, it will return the colour number, otherwise it will return a number between 0-100. You can do this in the middle of your code without any problems at all. - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat Aug 04, 2012 1:36 am |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: Redefining sensors.
Thanks. I never knew there was that.
That would save a lot of time.
|
| Sat Aug 04, 2012 1:56 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2859 Location: Rotterdam, The Netherlands
|
 Re: Redefining sensors.
So much to discover - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat Aug 04, 2012 2:17 am |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: Redefining sensors.
Another question. I really need to make the sensor switch modes extremely fast. I have tried and can only make than switch succesfully in approx. 160 milliseconds. What is the fastest the LEGO colour sensor can do?
|
| Sun Aug 05, 2012 2:04 am |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2859 Location: Rotterdam, The Netherlands
|
 Re: Redefining sensors.
That is pretty much the fastest it'll go. It is very slow to switch modes, I am not sure why that is.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Aug 05, 2012 11:33 am |
|
 |
|
mattallen37
Expert
Joined: Thu Sep 29, 2011 11:09 pm Posts: 146 Location: Michigan USA
|
 Re: Redefining sensors.
In full color mode, the FW reads the light level with no light (LED off), red light, green light, and blue light. The value provided as the "sensor value" is a color number based on the 4 values that it read. In NXC you can access these 4 values that the FW is reading, so unless for cosmetic reasons, there is usually no real functional reason to use any mode but full color mode. I don't know if ROBOTC supports something that, but it should, since the FW already knows the values, and it's just a matter of giving access to the user program. That way you can avoid the extremely long mode switching times, and have access to any value the sensor/FW can provide.
_________________ Matt
|
| Sun Aug 05, 2012 11:41 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2859 Location: Rotterdam, The Netherlands
|
 Re: Redefining sensors.
You can in ROBOTC, too. I'll see if I have some code to do that.
- Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sun Aug 05, 2012 11:50 pm |
|
|
|
Page 1 of 1
|
[ 8 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 6 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|