90 likes | 282 Views
Light, Sound, and Ultrasonic Sensor. Doc. leJOS API http://lejos.sourceforge.net/nxt/nxj/api/index.html leJOS Tutorial http://lejos.sourceforge.net/nxt/nxj/tutorial/index.htm. MMN Lab. Light Sensor. Constructor LightSensor(SensorPort port)
E N D
Doc • leJOS API • http://lejos.sourceforge.net/nxt/nxj/api/index.html • leJOS Tutorial • http://lejos.sourceforge.net/nxt/nxj/tutorial/index.htm MMN Lab.
Light Sensor • Constructor • LightSensor(SensorPort port) • LightSensor(SensorPort port, boolean floodlight) ) • Method • int readValue() • Higher numbers indicate more light • Int readNormalizedValue() MMN Lab.
Light Sensor cont’d • Sample program MMN Lab.
Sound Sensor • Constructor • SoundSensor(SensorPort port) • SoundSensor(SensorPort port, boolean dba) • Method • int readValue() • Void setDBA(boolean dba) MMN Lab.
Sound Sensor cont’d • Sample program MMN Lab.
Ultrasonic Sensor • Constructor • UltrasonicSensor (SensorPort port) • Method • int getDistance() MMN Lab.
Ultrasonic Sensor cont’d • Sample program MMN Lab.
Lab4 • Scenario • 1. Move forward until light sensor detects the black area • 2. Use the sound sensor such that the arm will hit the ball away after a indication • 3. Start to move and stop before bumping into the wall • Hint • For the arm, you can use Motor.PORT.Method to do some action MMN Lab.