To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 23875
23874  |  23876
Subject: 
Re: sensor-defined variable
Newsgroups: 
lugnet.robotics
Date: 
Wed, 13 Apr 2005 00:07:15 GMT
Viewed: 
1003 times
  
In lugnet.robotics, roc <principio@ilimit.es> wrote:

[pls excuse the newbieness of the question...]

   Hey, how do you think the rest of us learned? Perfectly all right

in NQC, can i have a variable defined by a sensor
to control parameters of, say, turn time of a motor,
or the note of a PlayTone(x,x)?

   Yes. The SENSOR_n (where n = 1, 2, or 3) is just the numerical reading from
the configured sensor. It's not a variable (you can not assign a value to it),
but you can use it as a source for calculations or decisions. For instance:

task main()
{
   SetSensor(SENSOR_1,SENSOR_LIGHT);
   while(true)
   {
      PlayTone(SENSOR_1*10,5);
      Wait(5);
   }
}

Try it and see.

--
Brian Davis



Message is in Reply To:
  sensor-defined variable
 
hi [pls excuse the newbieness of the question...] in NQC, can i have a variable defined by a sensor to control parameters of, say, turn time of a motor, or the note of a PlayTone(x,x)? thanks (19 years ago, 12-Apr-05, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR