Presentation is loading. Please wait.

Presentation is loading. Please wait.

THE LIGHT SENSOR The Light Sensor gives your robot some kind of vision. It can distinguish between light and dark assigning a number between 0 (completely.

Similar presentations


Presentation on theme: "THE LIGHT SENSOR The Light Sensor gives your robot some kind of vision. It can distinguish between light and dark assigning a number between 0 (completely."— Presentation transcript:

1 THE LIGHT SENSOR The Light Sensor gives your robot some kind of vision. It can distinguish between light and dark assigning a number between 0 (completely dark) and 100 (maximum light). It can also detect the light intensity of colored surfaces thanks to its Light Emitting Diode, so that it is possible to recognize colors.

2 SENSOR HARDWARE SCHEMATIC The circuit is not so simple, but it is easy to recognize the LED and the light sensor. On the right the input port connection is drawn. The NXT Light Sensor has a range of states between 0 and 100. The lower the number, the darker the reading is.

3 Connecting the light sensor to the NXT The input port and the cable have six connections. The connection can be used to get digital, analog and I2C signals and to supply power to the connected sensor.

4 What can you do with a light sensor? You can use the Light Sensor detect the light in a room. The Light Sensor can be use to follow a black line on a white floor. You can write a program that makes your robot move on a table without fall down.

5 NXC, is a high-level programming language for NXT. NXC has a syntax similar to C language. Before using a sensor you have to declare its connecting input: SetSensorLight( port number S1 to S4 ); To read a value and store it in a variable: x = Sensor(port number); Programming the Light Sensor with NXC

6 EXAMPLE PROGRAM task main() { SetSensorLight(S1); int x; while(true) { ClearScreen(); x=Sensor(S1); NumOut(10,LCD_LINE1,x); Wait(200); }


Download ppt "THE LIGHT SENSOR The Light Sensor gives your robot some kind of vision. It can distinguish between light and dark assigning a number between 0 (completely."

Similar presentations


Ads by Google