Upcoming SlideShare
×

# Programming with sensors bumper switch 1

5,788 views
5,634 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
5,788
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
9
0
Likes
0
Embeds 0
No embeds

No notes for slide

### 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