Let's Make Robots!

Help! Newbie in need of Arduino programming assistance.

Hello everybody! First let me start by apologizing, I've read the "newbies start here" post and I'm afraid I must break a few of the rules. I am a student at the Columbus College of Art and Design and I'm working on an installation that requires a pretty complicated (to me) set of robotics. I'm using an "Arduino Duemilanove" microcontroller with a "HiTec HS-322HD" servo and a "Lego NXT Sound Sensor." What I need to happen is for the servo to turn in degrees of db level present. So the more sound the NXT sensor picks up the further the servo will turn, and when there is no sound being picked up the servo returns to zero. I have taught myself as much as I can but have finally reached a point where I can't go any farther. What I need help with is having the NXT sensor communicate with the servo. I'm fairly familiar with the actionscript programming language, but there seems to only be a small amount of overlap between that and the Arduino language. Please Help! I'd be appreciated so much! -michael

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Im a fan of the lego mindstorms and it would be so much simpler if you just had the entire NXT kit. programming the NXT is like eating pie... with chopsticks, you get used to it. but the NXT has servo motors so it measures the rotation and hense can measrue your distance turned per dB. Yeah but heres some links.
http://www.youtube.com/watch?v=dahj51CMixA&feature=channel_page
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1239436328
The sound sensor is the problem. Without knowing what kind of circuit is inside or what kind of signal it delivers, things are kind of stuck. There is some information about how a Lego RCX sound sensor could be made but not on the NXT. It appears to give an analog signal, so perhaps researching how to connect and code the Arduino to analog signals would be a place to start. Wikipedia has a pinout diagram for NXT sensors, so it appears you only have to work with pins 1, 2, 3, and 4. I'd try powering the sensor by itself, and reading the signal on pin 1 with a meter, to see how high it gets. If it doesn't go above 5 volts, then you can probably connect it directly to the Arduino analog input and look at their code examples for reading analog values.

Yeah, I'm sorry, I forgot to mention that the NXT sensor's pinout is I2C, which is the main source of the problem. It can be put into the 5v pin, and then the SCL goes in pin 5 and SDA goes in pin 4. My main problem is that I'm having trouble with the Arduino code in how to interface with I2C. I've looked at multiple examples from their libraries on things like digital potentiometers (which is basically the essence of what I'm going for for) but I'm afraid most of it is over my head. I don't really know how to write the Arduino sketches competently enough to execute such a complicated set of code. 

Hi guys,

The NXT sound sensor is not I2C based. It's only the ultrasound sensor that is I2C based. As robologist suggests there is in fact an analog readout on pin 1 of the RJ12-ish connector.

LEGO has published schematics and docs for all the sensors and the NXT stuff on their web site: http://mindstorms.lego.com/Overview/NXTreme.aspx

Your program should look something like this:

  • Read analog input from microcontroller pin connected to pin 1 of NXT sensor connector
  • Scale this input to the range you need for the servo
  • Pulse servo 

Cheers,

Jimmy

The source for this is right on the arduinio page.....

it's pretty much plug and play from this point...

http://arduino.cc/en/Tutorial/Knob

edit: This would only be useful if the component were analogue, as it appears it may not be, this may not be as useful is I had thought.

I came across this link showing how to read the light sensor, and there's some theory presented on how the sensors work:

 

http://www.seattlerobotics.org/Encoder/200403/barello/LEGO%20sensors.html

 

The BASIC code looks pretty simple, maybe it is easily translated for the Arduino....

 

Good luck!

This information is regarding the "old" active sensors from the Robotics Invention System (MINDSTORMS 1.0, 1.5 and 2.0). The new NXT sensors are a lot simpler to handle due to their new 6-wire interface that holds analog readout, 4.3V, GND and I2C pins (SDA and SCL). This also means it is very easy to extend your NXT with new sensors or actuators that you build yourself.

Cheers,

Jimmy

Another possibility, have you checked to see if there is an analog signal present (on pin 1)? Might be easier than coding I2C.

Have you been through this write-up? My understanding of I2C is that you have to know the address of the device you want to talk with (the sensor) and use that in the first byte sent, then know the commands of the device (the sensor again) to know how to request data (by sending that byte next). Then the requesting device (Arduino) waits for the sensor to start clocking back data. Haven't written Arduino code, so can't really help with anything definitiive.

More here.

what does your code look like so far?

One thing I would suggest is getting the pot code to work first, then go with the nxt sensor. It'll end up being a similar algorthym for computing the input data to an output signal for the servo.

 You might want to write some code that isn't specific to the ardy(if you are familiar with perl or vbscript those work) that would do a similar function.