Post: VEX Programming
12-06-2012, 03:47 PM #1
OneWound
I am error
(adsbygoogle = window.adsbygoogle || []).push({}); task main()
{
while(1 == 1)
if (SensorValue(lightSensor1)<=200)
else
if (SensorValue(lightSensor2)<=200)
{
turnFlashlightOn(Flashlight1, 127);
turnFlashlightOn(Flashlight2, 127);
wait(10);
turnFlashlightOff(Flashlight1);
turnFlashlightOff(Flashlight2);
}
}
I'm taking a programming course using VEX kits in Natural Language. We are trying to get both of the flashlights to turn on the same time, and we can only get one to turn on. Ideas?
(adsbygoogle = window.adsbygoogle || []).push({});
12-06-2012, 06:21 PM #2
~SpongeBob
[move]Winning.[/move]
Do you have the outputs in the wrong ports?
I did an engineering class and we did a bit of programming with VEX, all i can say, its not worth what you pay for. Most of the sensors dont work..
but one thing i think you should add is { after the while 1 == 1 and at the end with the other }'s
12-06-2012, 08:33 PM #3
OneWound
I am error
Everything is in the right ports, and the flashlights both work (We switched the ports around and they worked. Replacing ) with } could make that much of a difference?
12-06-2012, 08:47 PM #4
GQGK
Skillz
Originally posted by OneWound View Post
Everything is in the right ports, and the flashlights both work (We switched the ports around and they worked. Replacing ) with } could make that much of a difference?


    task main() { 
while(1 == 1){
if (SensorValue(lightSensor1)<=200){
}
else if (SensorValue(lightSensor2)<=200)
{
turnFlashlightOn(Flashlight1, 127);
turnFlashlightOn(Flashlight2, 127);
wait(10);
turnFlashlightOff(Flashlight1);
turnFlashlightOff(Flashlight2);
}
}
}


That's what it should look like. Those brackets are very important. You're skipping over a lot of stuff without them. Also, formatting your code so it's readable really helps to avoid problems such as that...
12-07-2012, 05:00 PM #5
OneWound
I am error
I tried that code, and it doesn't seem to work. Then again, the code I used yesterday (could get both lightSensors to work), now only has one lightSensor working. I changed ports around and such to see if it was fault equipment, but it's not. I think it has something to do with the program itself

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo