![]() |
Programming ordeal
Hello fellow FTCers.
My name is Brian, new to FTC, this site, and robotics and general. My team is 5264, ILITE Blue Chips, from Haymarket. I am one of our team's programmers, and I have a slight problem, and was hoping someone could help. How do i set a light sensor to activate a LED light? For example, let's say I have a ligth sensor and 2 LED lights, one red, the other blue. When the sensor picks up anything >20, I want the red light to shine. then the sensor reads <20, I want the blue sensor to go off. How could I program this in ROBOTC? (Note: this isn't the exact scenario I'm in, but it's very similar) |
Re: Programming ordeal
Within main() you'd have something like this:
Code:
while(robot is running) {Turning red and blue on and off depends on the interface with the light; if it's the same as the standard NXT lamps, set the motor value corresponding to the port (eg. motor[motorA]) to 0 to turn it off, and to any other value up to 100 to turn it on at a given intensity (sign doesn't matter; the intensity at 100 is the same as at -100). |
Re: Programming ordeal
The plan slightly changed, now it's only one LED light. What i plan is when I press the button, the light will go on got weighted rings, and if I press the button and the button is unweighted, the light will not go on (maybe flash, not sure)
would this work? Quote:
|
Re: Programming ordeal
"turn red on" and "turn red off" aren't actual commands; you have to determine what the interface between the NXT and the LED is. If it's the same as a lamp, you control it like this:
Code:
motor[motorA] = 100; // Turn port A lamp on |
| All times are GMT -5. The time now is 02:16. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi