Exactly what Jon236 said: Just drag “4 wheel tank drive” over and drop it inside your while loop. This gives you four PWM outputs (2 victors per side, which is what you have!). The help function will tell you which PWM Outout goes to which motor (left or right).
OK, now that you’ve programmed tank drive, anything else you want to do?? (Yes, it is that easy…).
OK, Let’s talk about Inputs and Outputs.
Inputs give you blocks to handle any information that needs to come IN to the robot controller. Like a limit switch. For a limit switch, you would wire it up so it connects the Signal Pin of a Digital Input to ground when the switch is actuated (pressed). (The black wire of a Digital INput connection is ground). Then you’d read the condition of that digital input pin (using that digital input block you dragged in there), it will be a 1 or a 0 (not pressed or pressed) and you can use that somewhere else to make the robot do something.
In this case, you need to create and define a Variable (in the Variables section) with a name like “Limit_Switch_On_Arm” (something that explains what it does) as an INT (look up the different types of variables, maybe there’s a better choice?). Then, in the Digital Input block, you set the value of the Variable to whatever the input block is “seeing” from the limit switch (you also define which of the Digitial Inputs it’s connected to).
**
Outputs** are how you send something OUT of the robot controller - like to make a motor go or stop. So, to make the motor for your manipulator arm move, you can drop a motor block in there, define that it applies to motor (PWM) output #5 (or whatever), and tell the program which variable name (like “Arm_Motor_Output”) you’re using to set the PWM value, and it’ll do it.
Let’s say you want to make sure the motor won’t move forward after it hits the limit switch (In this example, “forward” is any PWM value from 128 to 255), you can do something like…
If
Limit_Switch_on_Arm = 1
If
Arm_Motor_Output >127
Then
Arm_Motor_Output == 127
EndIf
EndIf
Now, that “code” won’t really work, becasue you need to use ‘program flow’ blocks, input blocks and output blocks in there, not so many words.
Does this make some sense?
Here’s a project for you to try:
Wire up a switch to short the Digital Input 1 signal pin to ground when the switch is pressed.
Hook up the switch to Digital Input 1.
Hook up a victor to a motor, and to PWM output 8
When Digital Input 1 = 0 (the switch is pressed), set the output of PWM 8 to 250. Otherwise it is set to 127.
What should happen is that when the switch is pressed, the motor turns. When you let go of the switch, the motor stops.
The last point:
MAKE COMMENTS FOR EVERY SINGLE STEP. This is very important. It may seem stupid to you, but this is the way it is supposed to be done. Write a comment for every single step explaining what that step is supposed to do. Later, when your code is several hundred lines, and you don’t remember what you did (this WILL happen), the comments will help you a LOT. Use several lines of comments if you need to, and put in comments for major program blocks (there’s a Comment clock in the Program Flow library - its there for a good reason)
Have fun, and ASK QUESTIONS
Don