BEST Robotics Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
fredrick

Junior Member
Registered:
Posts: 5
Reply with quote  #1 
Need assistance on how to leave the servo in one position with one button and change it with another.
0
jgraber

Moderator
Registered:
Posts: 173
Reply with quote  #2 
That kind of thing is an easy step beyond "button go" . and on to "SPA" = Sense, Plan, Act.  yay.

Something like this pseudo code,

Go to the variable screen and make an integer variable to store the desired value of servo.  eg  ' int servo1_position'
// comment out joystick to motor port of servo
if (get Joystick digital button one) then {servo1_pos = 100;}  // SENSE and PLAN
if (get Joystick digital button two) then {servo1_pos = -100;}

SetMotor(servoMotor, servo1_pos);  // ACT . ; set motor and set servo do the exact same thing

Does that work for you? 
0
fredrick

Junior Member
Registered:
Posts: 5
Reply with quote  #3 
all this is for easy c, if yes in what part of the diagram should i input it?
0
jgraber

Moderator
Registered:
Posts: 173
Reply with quote  #4 
Yes, the pseudo code works in EasyC.  (  Also RobotC is similar)

Go to the variable screen (F6) ,  bottom half called Global Variables,
  make a new line,   set TYPE column to INT, Set NAME column to 'servo1_position'

The rest of the code goes inside the while(1) loop.
  Make sure you are not controlling that motor port with another command,  like Joystick_to_Motor(....)

0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.