View unanswered posts | View active topics It is currently Thu Jul 31, 2014 9:04 am






Reply to topic  [ 5 posts ] 
Code not working 
Author Message
Rookie

Joined: Mon Feb 03, 2014 3:28 am
Posts: 4
Post 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;
}
}
}


Mon Feb 03, 2014 3:35 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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.


Mon Feb 03, 2014 5:11 am
Profile
Rookie

Joined: Mon Feb 03, 2014 3:28 am
Posts: 4
Post Re: Code not working
when i push in the touch sensor it simly wont move at all but the code is still running


Fri Feb 28, 2014 3:11 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 558
Post 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)

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Feb 28, 2014 10:58 am
Profile
Rookie

Joined: Thu Jan 02, 2014 5:07 pm
Posts: 9
Post 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.

_________________
ADCAR
(Analog Digital Continuously Automous Robot)
Whew, Gary, the answer is still 42!


Mon Mar 03, 2014 4:56 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.