ROBOTC.net forums
http://www.robotc.net/forums/

Code not working
http://www.robotc.net/forums/viewtopic.php?f=63&t=7847
Page 1 of 1

Author:  Hephaestus59 [ Mon Feb 03, 2014 3:35 am ]
Post subject:  Code not working

Why is this not working :?:
task main ()
{
while (1 == 1)
{if(SensorValue[ledel] == 1)
{
motor[motorE] = 25;
}
if(SensorValue[ledel] < 0)
{
motor[motorE] = 0;
}
}
}

Author:  MHTS [ Mon Feb 03, 2014 5:11 am ]
Post subject:  Re: Code not working

What is not working? You need to tell us what this code is intending to do and what the code actually does. Without this info, nobody can tell you why the code is not working.

Author:  Hephaestus59 [ Fri Feb 28, 2014 3:11 am ]
Post subject:  Re: Code not working

when i push in the touch sensor it simly wont move at all but the code is still running

Author:  JohnWatson [ Fri Feb 28, 2014 10:58 am ]
Post subject:  Re: Code not working

Please post the entire code, including the #pragma statements, as we will need this information to ensure the correct button is being accessed by the code. As it stands right now, there is one major problem I am seeing:

Code:
if(SensorValue[ledel] < 0)


Touch sensors will only return a value of 0 or 1, and you won't have a condition where it returns a value less than 0. In short, this if statement's code will never execute. Instead, try this:

Code:
if(SensorValue[ledel] == 0)

Author:  adcar [ Mon Mar 03, 2014 4:56 pm ]
Post subject:  Re: Code not working

Check your open and closed brackets to make sure you don't have bad process logic. Post all your code, pin connections, OS, and RobotC version. That will help a lot.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/