View unanswered posts | View active topics It is currently Mon Nov 24, 2014 4:29 pm






Reply to topic  [ 3 posts ] 
Code Error---HELP! 
Author Message
Rookie

Joined: Fri Jan 27, 2012 12:12 pm
Posts: 2
Post Code Error---HELP!
Hi i am programming for two servos on the d-pad(tophat)

i am getting these errors

*Warning*:Assignment '=' embedded in expression
*Warning*:Assignment '=' embedded in expression

Code:
if(joystick.joy1_TopHat == 0) //if up is pressed on d pad
    {
    servo[servo1]=1 && servo[servo2]=1;
    }
    if(joystick.joy1_TopHat == 4) //if down is pressed on d pad
    {
    servo[servo1]=-1 && servo[servo2]=-1;


thank you in advanced


Fri Jan 27, 2012 12:16 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Code Error---HELP!
jplafor wrote:
Hi i am programming for two servos on the d-pad(tophat)

i am getting these errors

*Warning*:Assignment '=' embedded in expression
*Warning*:Assignment '=' embedded in expression

Code:
if(joystick.joy1_TopHat == 0) //if up is pressed on d pad
    {
    servo[servo1]=1 && servo[servo2]=1;
    }
    if(joystick.joy1_TopHat == 4) //if down is pressed on d pad
    {
    servo[servo1]=-1 && servo[servo2]=-1;


thank you in advanced


Welcome to the forums!!

Assuming I'm understanding your code correctly, your assigning values to servos, correct? If so, you can't set the status of two things like that in in the same line of code. Does this version work?

Code:
if(joystick.joy1_TopHat == 0) //if up is pressed on d pad
    {
    servo[servo1]=1;
    servo[servo2]=1;
    }
    if(joystick.joy1_TopHat == 4) //if down is pressed on d pad
    {
    servo[servo1]=-1;
    servo[servo2]=-1;


I think your getting that warning 'cause if you use the "&&" operator, it's looking for a "if" statement and the "==" that looks for a matching value.

Does this help?

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Fri Jan 27, 2012 12:49 pm
Profile WWW
Rookie

Joined: Fri Jan 27, 2012 12:12 pm
Posts: 2
Post Re: Code Error---HELP!
Amazing... worked perfectly! thank you so much for all the help


Sat Jan 28, 2012 11:32 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.