Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
×

Programming with sensors bumper switch 1

7,509 views

Published on

• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Programming with sensors bumper switch 1

1. 1. VEX Robotics I Power Points Topic 09 Programming Design Basics Bumper Switch Sensing 1www.pedagogics.ca
2. 2. Topics Covered in this Presentation Topic 09 • Introduction to the bumper switch • flowcharting and writing pseudocode •program sketch #1 • while loops and Boolean logic • if else loops and sensor input
3. 3. Bumper Switch(digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 0
4. 4. Bumper Switch(digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 1
5. 5. Bumper Switch(digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 0
6. 6. Bumper Switch(digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 1
7. 7. Program sketch #1Write a simple program to make your robot drive forwardindefinitely , but will stop, turn 180o and continue driving ifthe robot encounters an obstacle. STEP 1 – FLOWCHART • thinking about how ROBOTC works STEP 2 – PSEUDOCODE STEP 3 – ACTUAL CODE
8. 8. Flowchart Symbols
9. 9. START Flow chart describes behavior sequence. DRIVE FORWARD This flowchart gives us the basicNO idea of what behaviors we want to Switch pressed see in our robot. ? YES The flowchart however is overly simplified and needs a few extras to Stop, reverse, 180 degree turn make it easily transferable to code.
10. 10. Cannot use a wait statement because we want START the robot to perform two functions alternately (essentially simultaneously) IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARDMoveon loop ? FALSE END Stop, reverse, 180 degree turn
11. 11. DECISIONS must This type of question is called a Booleanbe thought of as statement. questions thatcan be answered The answer is called a “truth value” and YES or NO the answer is only valid at the time the TRUE or FALSE question is asked. You used a Boolean statement in the remote control coding for Tumbler
12. 12. Valid “comparison operators” in ROBOTC
13. 13. STARTPseudo code - basic commands, comments aboutfunctions and behaviorsThis code will never compileForms the backbone of your program and translatesfrom the flowchart to ROBOTC
14. 14. IF , ELSE boolean statement used to check bumper switch. If switch is not pressed, robotSTART drives forward IF Always Switch TRUEWHILE DRIVE notLOOP ? infinite pressed FORWARD loop ?
15. 15. IF , ELSE boolean statement used to checkSTART bumper switch. If switch is not pressed, robot drives forward IF Always Switch TRUEWHILE DRIVE notLOOP ? infinite pressed FORWARD loop ?
16. 16. If switch is pressed – ELSE – the stop and turnSTART behavior occurs, then robot returns to moving forward (unless what is happening?) IF Always Switch TRUEWHILE DRIVE notLOOP ? infinite pressed FORWARD loop ? FALSE Stop, reverse, 180 degree turn
17. 17. START IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARDMoveon loop ? FALSE END Stop, reverse, 180 degree turn