Quote:
Originally Posted by MonikkaM
she's not clear on a) how the sensor is addressed by the program
|
It's in the #pragma the sensors/servos configuration dialog box puts in for you.
In the example code Team_2488 put in for you above, it's this statement:
#pragma config(Sensor, S2, HTMAG, sensorHiTechnicMagnetic)
Quote:
b) how to use whatever data is being gathered by the sensor, c) whether or not she installed it properly and d) can/how does she hook up a light bulb to tell her if the ball is magnetic or not?
|
For b), Team_2488's code will indeed work; we used a magnetic reed switch and had to debounce it

.
For c), hook up an LED... and try waving a ball in front of the sensor.
For d), Team_2488 is telling you to splice the LED in the servo wires. Do you have a HiTechnic Prototype Board in your robot? If so, you can use a B0-B5 output for your LED (put a statement in the if branches that throw the servo to turn the light on and leave it on).
Otherwise, you'll only know you have a magnet ball if you happen to be looking at the LED while the servo is moving. Since the code they've shown is blocking (meaning 'doesn't return to the event/main loop until done'), and they have a 1s timeout, you'll both need to have your servo throw done and no time to really tell if the light is on... and that doesn't help at all if you are looking for the LED to tell the human operator to activate the servo.
If you're leaving the decision to throw the servo to the NXT controller software, then you can indicate you have a magnet ball after the fact by putting a switch in the magnet ball repository (a roller momentary-contact switch works well), and use that to close a circuit to light the LED.