View unanswered posts | View active topics It is currently Sat Nov 01, 2014 1:28 am






Reply to topic  [ 2 posts ] 
How to use LEGO RGB sensor to measure ambience lighting. 
Author Message
Rookie

Joined: Sat Jun 29, 2013 10:08 pm
Posts: 1
Post How to use LEGO RGB sensor to measure ambience lighting.
I want to be able to measure the level of lighting in an area.
For example lets say I want to make a robot using the RGB color sensor, that moves from an area of "darkness" in the room, to an area which has some light.
I was going through the example code. From what I could understand, would something like the snippet below help me detect ambient lighting level?
How do I make sense of the values that show up. I am guessing 0 mean dark and something close to 1023 means light?

I am not sure whether the raw or the Atod value is the appropriate one.
Do i need a special type of light in the room for the color sensor to work in this way?

Or is it simply not possible to do this using the RGB sensor.?
Code:
#pragma config(Sensor, S1,     ,               sensorSONAR)
#pragma config(Sensor, S2,    colorport,       sensorCOLORFULL)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
   short analog_to_digital[4];
   short raw[4];
   
   while (true) {
      getColorSensorData(colorport, colorAtoD, analog_to_digital);
      getColorSensorData(colorport, colorRaw, raw);   
      nxtDisplayString(0, "ATod = %i", analog_to_digital[3]);
      nxtDisplayString(1, "Raw = %i", raw[3]);
      wait1Msec(1000);
   }
}




Sat Jun 29, 2013 10:44 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: How to use LEGO RGB sensor to measure ambience lighting.
Code:
#pragma config(Sensor, S1,     color,               sensorCOLORNONE)

Read like normal, with SensorValue. 0 = dark, 100 = light.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Sat Jun 29, 2013 10:51 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  
cron



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.