<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.robotc.net/w/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.robotc.net/w/index.php?title=NXT_Sensors_Overview&amp;feed=atom&amp;action=history</id>
		<title>NXT Sensors Overview - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.robotc.net/w/index.php?title=NXT_Sensors_Overview&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://www.robotc.net/w/index.php?title=NXT_Sensors_Overview&amp;action=history"/>
		<updated>2013-06-18T04:41:30Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://www.robotc.net/w/index.php?title=NXT_Sensors_Overview&amp;diff=1835&amp;oldid=prev</id>
		<title>Bfeher: Created page with &quot;&lt;yambe:breadcrumb self=&quot;Sensors Overview&quot;&gt;NXT|NXT&lt;/yambe:breadcrumb&gt;   {| class=&quot;wikiText&quot; |- |''For ROBOTC NXT Sensor ''functions'', check out the [[NXT_Functions_Sensors|NXT...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.robotc.net/w/index.php?title=NXT_Sensors_Overview&amp;diff=1835&amp;oldid=prev"/>
				<updated>2012-04-18T20:22:59Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;yambe:breadcrumb self=&amp;quot;Sensors Overview&amp;quot;&amp;gt;NXT|NXT&amp;lt;/yambe:breadcrumb&amp;gt;   {| class=&amp;quot;wikiText&amp;quot; |- |&amp;#039;&amp;#039;For ROBOTC NXT Sensor &amp;#039;&amp;#039;functions&amp;#039;&amp;#039;, check out the [[NXT_Functions_Sensors|NXT...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;yambe:breadcrumb self=&amp;quot;Sensors Overview&amp;quot;&amp;gt;NXT|NXT&amp;lt;/yambe:breadcrumb&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikiText&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|''For ROBOTC NXT Sensor ''functions'', check out the [[NXT_Functions_Sensors|NXT Sensor Functions]] page!''&lt;br /&gt;
&lt;br /&gt;
''For information and examples on using I2C sensors, head over to [[NXT_I2C_Sensors|NXT I2C Digital Sensors]] page!''&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{tl|1|}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Touch Sensor ==&lt;br /&gt;
{| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|The NXT Touch Sensor has 2 states, pressed or unpressed.  In code this is represented with a 1 for pressed, and a 0 for unpressed.  There are no other states for this sensor.  Below is a simple program that keeps your program from running until you press the Touch Sensor.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;ROBOTC&amp;quot;&amp;gt;&lt;br /&gt;
#pragma config(Sensor, S1,     touchSensor,         sensorTouch)&lt;br /&gt;
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//&lt;br /&gt;
&lt;br /&gt;
task main()&lt;br /&gt;
{&lt;br /&gt;
  while(SensorValue(touchSensor) == 0)  // while the Touch Sensor is inactive (hasn't been pressed):&lt;br /&gt;
  {&lt;br /&gt;
    // DO NOTHING (wait for press)&lt;br /&gt;
  }&lt;br /&gt;
  while(SensorValue(touchSensor) == 1)  // while the Touch Sensor is active (pressed):&lt;br /&gt;
  {&lt;br /&gt;
    // DO NOTHING (wait for release)&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // YOUR CODE GOES HERE&lt;br /&gt;
                                        // otherwise (the touch sensor has been activated [pressed] ):&lt;br /&gt;
  motor[motorB] = 75;                   /* run motors B and C forwards */&lt;br /&gt;
  motor[motorC] = 75;                   /* with a power level of 75    */&lt;br /&gt;
  wait1Msec(1000);                      // wait 1000 milliseconds (1 second) before moving to further code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Light Sensor ==&lt;br /&gt;
{| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|The NXT Light Sensor has a range of states between 0 and 100.  The lower the number, the darker the reading is.  The higher the number, the lighter the reading is.  Below is a simple line-following program that uses only one NXT Light Sensor.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;ROBOTC&amp;quot;&amp;gt;&lt;br /&gt;
#pragma config(Sensor, S3,     lightSensor,         sensorLightActive)&lt;br /&gt;
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//&lt;br /&gt;
&lt;br /&gt;
task main()&lt;br /&gt;
{&lt;br /&gt;
   wait1Msec(50);                        // The program waits 50 milliseconds to initialize the light sensor.&lt;br /&gt;
   while(true)                           // Infinite loop&lt;br /&gt;
   {&lt;br /&gt;
      if(SensorValue(lightSensor) &amp;lt; 45)  // If the Light Sensor reads a value less than 45:&lt;br /&gt;
      {&lt;br /&gt;
        motor[motorB] = 60;                  // Motor B is run at a 60 power level.&lt;br /&gt;
        motor[motorC] = 20;                  // Motor C is run at a 20 power level.&lt;br /&gt;
      }&lt;br /&gt;
      else                               // If the Light Sensor reads a value greater than or equal to 45:&lt;br /&gt;
      {&lt;br /&gt;
        motor[motorB] = 20;                  // Motor B is run at a 20 power level.&lt;br /&gt;
        motor[motorC] = 60;                  // Motor C is run at a 60 power level.&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sound Sensor ==&lt;br /&gt;
{| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|The NXT Sound Sensor has a range of states between 0 and 100.  The lower the number, the quieter the reading is.  The higher the number, the louder the reading is.  Below is a simple program that maps the Sound Sensor reading to the motor speeds.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;ROBOTC&amp;quot;&amp;gt;&lt;br /&gt;
#pragma config(Sensor, S2,     soundSensor,         sensorSoundDB)&lt;br /&gt;
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//&lt;br /&gt;
 &lt;br /&gt;
task main()&lt;br /&gt;
{&lt;br /&gt;
  wait1Msec(1000);       // A one-second wait is required to cleanly initialize the Sound Sensor.&lt;br /&gt;
  while(true)            // Infinite loop&lt;br /&gt;
  {&lt;br /&gt;
    motor[motorB] = SensorValue[soundSensor];    /* Motors B and C are run at a power level equal */&lt;br /&gt;
    motor[motorC] = SensorValue[soundSensor];    /* to the value read in by the Sound Sensor.     */&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ultrasonic (sonar) Sensor ==&lt;br /&gt;
{| style=&amp;quot;font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;&amp;quot; width=&amp;quot;100%&amp;quot; cellpadding=&amp;quot;5%&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|The NXT Ultrasonic Sensor has a range of states between 0 and 255.  This number is representative of the current reading in centimeters.  However, a reading of 255 means that the current sensor reading is out of range.  This is a &amp;quot;range error&amp;quot; and means that the echo is not being read back (looking down a long hall for example).  A reading outside of these numbers indicates that there is no sensor attached or some error with the connection.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;syntaxhighlight lang=&amp;quot;ROBOTC&amp;quot;&amp;gt;&lt;br /&gt;
#pragma config(Sensor, S4,     sonarSensor,         sensorSONAR)&lt;br /&gt;
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//&lt;br /&gt;
&lt;br /&gt;
task main()&lt;br /&gt;
{&lt;br /&gt;
  int distance_in_cm = 20;   // Create variable 'distance_in_cm' and initialize it to 20(cm).&lt;br /&gt;
  while(SensorValue[sonarSensor] &amp;gt; distance_in_cm)   /* While the Sonar Sensor readings are greater */&lt;br /&gt;
  }                                                  /* than the specified, 'distance_in_cm':       */&lt;br /&gt;
    motor[motorB] = 75;                     // Motor B is run at a 75 power level&lt;br /&gt;
    motor[motorC] = 75;                     // Motor C is run at a 75 power level&lt;br /&gt;
  }&lt;br /&gt;
  motor[motorB] = 75;    // Motor B is stopped at a 0 power level&lt;br /&gt;
  motor[motorC] = 75;    // Motor C is stopped at a 0 power level&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bfeher</name></author>	</entry>

	</feed>