Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming - Buttons Intro to Robotics.

Similar presentations


Presentation on theme: "Programming - Buttons Intro to Robotics."— Presentation transcript:

1 Programming - Buttons Intro to Robotics

2 Ch 5 & 6 Joysticks work by moving the stick along an axis and thus any value between 127 & -127 can be sent. With the buttons they are either pushed or not pushed. So only SPECIFIC values can be sent.

3 Fear of Disqualification?
You added the wait1Msec( ) command in the beginning of the code to give you a chance to move out of the way before commands are given. But what happens if you accidentally touch the joystick? Or what happens if the signal is given BEFORE your timer runs out?

4 Remote Start?

5 Open the program we were working on the last time we met.
Compile and download the program. Test the button function.

6 Use an Idle Loop

7 Your program should look like this
Make sure you SAVE this file in you’re MY DOCUMENTS folder.

8 What about the button on the robot?
We first need to add the sensor as a “touch” type sensor. Make sure the button itself is plugged into INT1.

9 Choose the sensors 1-8 tab. In “in1” for the “name” enter button
Choose the sensors 1-8 tab. In “in1” for the “name” enter button . For the “type” choose “Touch

10

11 “If” statement Remember that IF statements can be used to create “conditional” commands that will NOT loop.

12 If-Else

13 Lets add the “IF-ELSE” statement
The condition here is called “Sensorvalue” and the sensor is the name we used in the setup menu, “button”. We are setting the condition equal to ZERO because when the button is OPEN we want to be able to use the RC. The false condition or “else” is that if the button does NOT read ZERO or ONE(closed) we turn OFF the motors for 3 seconds. Notice this is within the while loop.

14 Let’s Check your understanding
Using “comments” IN YOUR OWN WORDS, insert them under each control structure and command statements explaining what they do. Place your name in the code (using comments) and print out the code and turn it in.

15 Ready for Soccer? Compile and test your program Test your idle loop
Test your IF/ELSE statement Test your timer Get my approval for competition


Download ppt "Programming - Buttons Intro to Robotics."

Similar presentations


Ads by Google