/////////////////////////////////////////////////////////////////////////////// // // Original System: LEGO Robotics Sample Code // Subsystem: Light sensor sample reader // Workfile: light.nxc // Revision: 1.0 - 1 December, 2008 // Author: J. Marvel // // Description // =========== // Sample code for reading reading the raw value from an attached light // sensor. /////////////////////////////////////////////////////////////////////////////// //! @brief The main program loop //! task main() { //! Declare your variables here int n, c = 0; string s, t; //! Configure sensor port #1 for a light sensor with the reference light //! active SetSensorType(S1, SENSOR_TYPE_LIGHT_ACTIVE); //! Play a single tone with frequency 262 at volume 5 for 0.4 seconds, do not //! loop PlayToneEx(262, 400, 4, FALSE); //! Pause for half a second Wait(500); while (true) { //! Read and display the raw information from the light sensor n = Sensor(IN_1); s = NumToStr(n); TextOut(15, LCD_LINE1, s, true); //! Display the loop iteration for timing assessment t = NumToStr(c); TextOut(15, LCD_LINE2, t, true); c++; } }