|
Page 1 of 1
|
[ 2 posts ] |
|
Using Pushbutton as a Toggle Switch?
Author |
Message |
Kaden
Rookie
Joined: Wed Apr 30, 2008 1:50 pm Posts: 3 Location: Burnaby, BC
|
 Using Pushbutton as a Toggle Switch?
Hey!
I'm new to this whole NXT thing, but not new to C programming, and I was wondering if anyone knows the capabilities of the push button, would I be able to use it as a toggle switch, and if so, does ROBOTC have a function that deals with that or should I be writting my own? I'm used to binary toggleing, so I may have some questions on how to make it un binary.
Thanks
|
Wed Apr 30, 2008 1:53 pm |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
Hi Kaden
The push button that comes with the NXT is a simple contact switch on the inside, and only returns boolean values. The sensor is a little deceiving, It does look like it could be a toggle switch. Its big and the end can pivot somewhat to allow more versatile ways to push it.
You can read the sensor multiple ways however, you can set it up as a boolean, returning a 1 OR 0, or as a passive sensor and get values in between 0% and 100%. Another way people don't take much notice to is PulseCount, which reads how many times the sensor is pressed and released, not the current state of the switch.
Here are some example pieces that show how to change the mode of a sensor
SensorMode[S1] = modeBoolean;
SensorMode[S1] = modePercentage;
SensorMode[S1] = modePulseCount;
RobotC defined sensor modes, can apply these to any sensor
* modeBoolean
* modeDummy
* modeEdgeCount
* modePercentage
* modePulseCount
* modeRaw
* modeRotation
* modeTemperatureC
* modeTemperatureF
Did I answer your question? Good luck with your project, and welcome to RobotC B-)
Scott
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
Wed Apr 30, 2008 4:25 pm |
|
|
|
Page 1 of 1
|
[ 2 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|