Hello everybody.
I am having an issue with the new colour sensor. I am trying to program it so that it stops the robot when bright light is detected yet I cannot seem to do this. When I use the brick to View the ambient / reflected light values from the sensor they stay at 100% no matter what I do. I tried calibrating it but it always displays the raw value of 1023 under any light condition. I should mention this is with LEDs off. I have scoured the internet and what I seem to come across is that the new colour sensor has slightly different programming requirements and I would be grateful if somebody pointed me in the right direction such as an updated programming guide etc. I use Bricxcc to code. Any help will be appreciated.
NXT 2.0 New Color Sensor Issue
Re: NXT 2.0 New Color Sensor Issue
The first step toward resolving this problem is for you to post your non-working NXC code here. That will help us figure out what you are trying to do and how to help you successfully do what you are trying to do.
John Hansen
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 3
- Joined: 22 Sep 2011, 14:10
Re: NXT 2.0 New Color Sensor Issue
Yeah that probably would have been a good idea I just whipped up some simple code to test out the functionality of the new sensor. Basically it is supposed to keep the robot moving until it senses bright light then it will stop and play a sound.
Code: Select all
#define THRESH 70
task main()
{
// Initiates sensor as an ambient light sensor
SetSensorType(IN_3,IN_TYPE_LIGHT_ACTIVE);
SetSensorMode(IN_3,IN_MODE_PCTFULLSCALE);
ResetSensor(IN_3);
OnFwd(OUT_BC, 75);
while (true) // Continue the execution of code
{
if (SENSOR_3 > THRESH)
{
Off(OUT_BC); Wait(100);
PlayFileEx("annoy.rso", 4, 0);
until(SENSOR_3 <= THRESH);
OnFwd(OUT_BC, 75);
}
}
Re: NXT 2.0 New Color Sensor Issue
So, you can't use the old light sensor types/modes with the NXT 2.0 color sensor.
Search the NXC help for SetSensorColor. You'll see a few API functions for configuring the NXT 2.0 color sensor. If you want to turn off the LED so that it does not shine red, blue, or green then use SetSensorColorNone.
Another thing to mention is that the IN_ constants from NBCCommon.h are meant for use in NBC code and it is generally recommended that you use the SENSOR_TYPE_*, SENSOR_MODE_*, and S1..S4 constants from NXCDefs.h instead.
Once you have configured the color sensor using SetSensorColorNone you should be able to read the sensor value using SENSOR_3.
John Hansen
Search the NXC help for SetSensorColor. You'll see a few API functions for configuring the NXT 2.0 color sensor. If you want to turn off the LED so that it does not shine red, blue, or green then use SetSensorColorNone.
Another thing to mention is that the IN_ constants from NBCCommon.h are meant for use in NBC code and it is generally recommended that you use the SENSOR_TYPE_*, SENSOR_MODE_*, and S1..S4 constants from NXCDefs.h instead.
Once you have configured the color sensor using SetSensorColorNone you should be able to read the sensor value using SENSOR_3.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
-
- Posts: 3
- Joined: 22 Sep 2011, 14:10
Re: NXT 2.0 New Color Sensor Issue
Thanks a lot. I found the API's that worked with the new colour sensor. Much appreciated!
-
- Posts: 1
- Joined: 23 Oct 2011, 18:04
Re: NXT 2.0 New Color Sensor Issue
Hi, me too, I have a problem with the new light sensor. I would like to access it from the normal lego provided software. It seems that the sensor reads 1023 both in dark, both in direct light (tried with embedded try me software and a custom one). There is an other way to test it?
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: NXT 2.0 New Color Sensor Issue
roxindrang wrote:Hi, me too, I have a problem with the new light sensor. I would like to access it from the normal lego provided software. It seems that the sensor reads 1023 both in dark, both in direct light (tried with embedded try me software and a custom one). There is an other way to test it?
...as john just wrote:So, you can't use the old light sensor types/modes (and blocks) with the NXT 2.0 color sensor.
---> Link to lots of MINDSTORMS stuff under my picture --->
Who is online
Users browsing this forum: No registered users and 4 guests