LightSensor and Sound Sensor

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

LightSensor and Sound Sensor

Postby Shinigami » Sat Oct 27, 2007 1:26 am

I wanna use the lightSensor but I don't know how to use it

I wanna make the robot follow a colored line(e.g Black line) but I really don't know how to make the sensor work fine.

Does anyone has an example program using it?


Another problem:

We're having some problems with the soundsensor. We want to make the robot go to the left when hand is clapped one time, and to the right when hand is clapped two times, is it possible?
In Our tests we couldn't know how to make this recognition work. Is is based on dba? Can it recognize voice?

Thanks for all! Sorry, we're newbies :lol:
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm

Re: LightSensor and Sound Sensor

Postby bbagnall » Sat Oct 27, 2007 5:44 pm

Shinigami wrote:I wanna use the lightSensor but I don't know how to use it

I wanna make the robot follow a colored line(e.g Black line) but I really don't know how to make the sensor work fine.

Does anyone has an example program using it?

You should check out the API docs, they tell you everything. There are also some samples in the samples directory.

LightSensor light = new LightSensor(SensorPort.S1);
int lightReading = light.readValue();

Shinigami wrote:We're having some problems with the soundsensor. We want to make the robot go to the left when hand is clapped one time, and to the right when hand is clapped two times, is it possible?
In Our tests we couldn't know how to make this recognition work. Is is based on dba? Can it recognize voice?

It just measures loudness of sounds (any sound) in Decibels. Try a simple program that outputs the decibel level to the LCD screen and start making noises to see how it reacts.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby Shinigami » Tue Nov 06, 2007 10:19 am

What's class error 20?
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm

Postby DigitalOne » Tue Nov 06, 2007 7:37 pm

I have no idea what that error means but this links to a post I made in the Projects forum that answers your first question in your original post.

http://lejos.sourceforge.net/forum/viewtopic.php?t=549

This works with 3 of the 4 sensors by changing the obvious in the code. The only sensor that this doesn't work with is the touch sensor since it returns a boolean value instead of an int value.
"I would kill everyone in this room for a drop of sweet beer." -Homer Simpson
User avatar
DigitalOne
New User
 
Posts: 7
Joined: Tue Oct 23, 2007 6:20 pm
Location: America's Wang

Postby Shinigami » Tue Nov 06, 2007 8:32 pm

DigitalOne wrote:I have no idea what that error means but this links to a post I made in the Projects forum that answers your first question in your original post.

http://lejos.sourceforge.net/forum/viewtopic.php?t=549

This works with 3 of the 4 sensors by changing the obvious in the code. The only sensor that this doesn't work with is the touch sensor since it returns a boolean value instead of an int value.


Thanks, we found the problem.

Hey ppl, sorry being so boring asking questions, we want to make the robot follow a light, is is possible?

Does anyone have any program like this one?

Thank you very much!
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm

Postby roger » Wed Nov 07, 2007 4:45 am

Shinigami wrote:Hey ppl, sorry being so boring asking questions, we want to make the robot follow a light, is is possible?

Does anyone have any program like this one?

Sure it is possible. In Java, almost anything is. I don't have program for your, but here is an idea you might try. Use a Pilot object steer() method to travel in a curved path. When the light sensor values sensor values increase to a maximum then starts to decrease, steer in the opposite direction.
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff