SlideShare une entreprise Scribd logo
1  sur  22
VEX Robotics I Power Points
                             Topic 09
                    Programming Design Basics
                     Bumper Switch Sensing 1
www.pedagogics.ca
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
Bumper Switch
(digital sensor)




      Usually positioned on front of robot.
      Output is either a 1 (depressed) or a 0




                                          0
Bumper Switch
(digital sensor)




      Usually positioned on front of robot.
      Output is either a 1 (depressed) or a 0




                                          1
Bumper Switch
(digital sensor)




      Usually positioned on front of robot.
      Output is either a 1 (depressed) or a 0




                                          0
Bumper Switch
(digital sensor)




      Usually positioned on front of robot.
      Output is either a 1 (depressed) or a 0




                                          1
Program sketch #1
Write a simple program to make your robot drive forward
indefinitely , but will stop, turn 180o and continue driving if
the robot encounters an obstacle.


                    STEP 1 – FLOWCHART
                       • thinking about how ROBOTC works


                    STEP 2 – PSEUDOCODE


                    STEP 3 – ACTUAL CODE
Flowchart Symbols
START          Flow chart describes behavior
                          sequence.
          DRIVE
        FORWARD
                          This flowchart gives us the basic
NO
                          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.
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                FORWARD
Move
on                    loop               ?

                                            FALSE

       END                       Stop, reverse, 180
                                    degree turn
DECISIONS must     This type of question is called a Boolean
be thought of as   statement.
 questions that
can 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
Valid “comparison operators” in ROBOTC
START




Pseudo code - basic commands, comments about
functions and behaviors

This code will never compile

Forms the backbone of your program and translates
from the flowchart to ROBOTC
IF , ELSE boolean statement used to check
             bumper switch. If switch is not pressed, robot
START        drives forward



                         IF
         Always       Switch     TRUE
WHILE                                         DRIVE
                        not
LOOP ?
         infinite     pressed               FORWARD
         loop            ?
IF , ELSE boolean statement used to check
START        bumper switch. If switch is not pressed, robot
             drives forward


                         IF
         Always       Switch     TRUE
WHILE                                         DRIVE
                        not
LOOP ?
         infinite     pressed               FORWARD
         loop            ?
If switch is pressed – ELSE – the stop and turn
START        behavior occurs, then robot returns to moving
             forward (unless what is happening?)


                            IF
         Always          Switch          TRUE
WHILE                                             DRIVE
                           not
LOOP ?
         infinite        pressed                FORWARD
         loop               ?

                               FALSE

                    Stop, reverse, 180
                       degree turn
START



                                         IF
                      Always          Switch          TRUE
             WHILE                                             DRIVE
                                        not
             LOOP ?
                      infinite        pressed                FORWARD
Move
on                    loop               ?

                                            FALSE

       END                       Stop, reverse, 180
                                    degree turn
Programming with sensors   bumper switch 1

Contenu connexe

Tendances

Projet de fin d'etude :Control d’acces par empreintes digitale
Projet de fin d'etude :Control d’acces par empreintes digitaleProjet de fin d'etude :Control d’acces par empreintes digitale
Projet de fin d'etude :Control d’acces par empreintes digitaleAbdo07
 
Model Based Testing des applications du protocole MQTT
Model Based Testing des applications du protocole MQTTModel Based Testing des applications du protocole MQTT
Model Based Testing des applications du protocole MQTTymelka
 
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATURE
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATUREARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATURE
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATUREHajer Dahech
 
Electronique+numerique+logique+combinatoire+et+sequentielle
Electronique+numerique+logique+combinatoire+et+sequentielleElectronique+numerique+logique+combinatoire+et+sequentielle
Electronique+numerique+logique+combinatoire+et+sequentiellemorin moli
 
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...Paul Biya
 
Differents bus terrain
Differents bus terrainDifferents bus terrain
Differents bus terrainImed Frioukh
 
M25 installation et dipanage de moteur a courant continu
M25 installation et dipanage de moteur a courant continuM25 installation et dipanage de moteur a courant continu
M25 installation et dipanage de moteur a courant continuMOUHSSINE BEN HAMMOU
 
Schemas appareillages-master1-cours benaired
Schemas appareillages-master1-cours benaired Schemas appareillages-master1-cours benaired
Schemas appareillages-master1-cours benaired morin moli
 
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...Modélisation et commande de la machine asynchrone par jean pierre caron jean ...
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...sofiane dahmane
 
Chapitre I. introduction au reseau informatique
Chapitre I. introduction au reseau informatiqueChapitre I. introduction au reseau informatique
Chapitre I. introduction au reseau informatiqueLycée Technique de BIKOK
 
PFE régulateur de vitesse d'un moteur DC
PFE régulateur de vitesse d'un moteur DCPFE régulateur de vitesse d'un moteur DC
PFE régulateur de vitesse d'un moteur DCMohamed Arhoujdam
 
Automatisation d'une maison intelligente via une application android
Automatisation d'une maison intelligente via une application androidAutomatisation d'une maison intelligente via une application android
Automatisation d'une maison intelligente via une application androidAbderrahim Bouharaoua
 
Etude d'installation électrique et réalisation de l'armoire électrique TGBT
Etude d'installation électrique et réalisation de l'armoire électrique TGBTEtude d'installation électrique et réalisation de l'armoire électrique TGBT
Etude d'installation électrique et réalisation de l'armoire électrique TGBTSadokZgolli
 
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdf
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdfRapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdf
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdfEmeric Kamleu Noumi
 
Le grand livre d'Arduino pdf
Le grand livre d'Arduino pdfLe grand livre d'Arduino pdf
Le grand livre d'Arduino pdfkinziramtane
 
Télécharger livre - schéma d'installation électrique
Télécharger livre - schéma d'installation électriqueTélécharger livre - schéma d'installation électrique
Télécharger livre - schéma d'installation électriquemorin moli
 
Alfabeto di arduino - lezione 4
Alfabeto di arduino - lezione 4Alfabeto di arduino - lezione 4
Alfabeto di arduino - lezione 4Michele Maffucci
 

Tendances (20)

Projet de fin d'etude :Control d’acces par empreintes digitale
Projet de fin d'etude :Control d’acces par empreintes digitaleProjet de fin d'etude :Control d’acces par empreintes digitale
Projet de fin d'etude :Control d’acces par empreintes digitale
 
Mémoire.pdf
Mémoire.pdfMémoire.pdf
Mémoire.pdf
 
SMART Home Rapport
SMART Home RapportSMART Home Rapport
SMART Home Rapport
 
Model Based Testing des applications du protocole MQTT
Model Based Testing des applications du protocole MQTTModel Based Testing des applications du protocole MQTT
Model Based Testing des applications du protocole MQTT
 
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATURE
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATUREARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATURE
ARDUINO + LABVIEW : CONTRÔLE DE LA TEMPÉRATURE
 
Electronique+numerique+logique+combinatoire+et+sequentielle
Electronique+numerique+logique+combinatoire+et+sequentielleElectronique+numerique+logique+combinatoire+et+sequentielle
Electronique+numerique+logique+combinatoire+et+sequentielle
 
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...
Paul Biya - Cameroun - Décret N°384 du 26 septembre 2014 portant organisation...
 
Differents bus terrain
Differents bus terrainDifferents bus terrain
Differents bus terrain
 
M25 installation et dipanage de moteur a courant continu
M25 installation et dipanage de moteur a courant continuM25 installation et dipanage de moteur a courant continu
M25 installation et dipanage de moteur a courant continu
 
Schemas appareillages-master1-cours benaired
Schemas appareillages-master1-cours benaired Schemas appareillages-master1-cours benaired
Schemas appareillages-master1-cours benaired
 
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...Modélisation et commande de la machine asynchrone par jean pierre caron jean ...
Modélisation et commande de la machine asynchrone par jean pierre caron jean ...
 
Chapitre I. introduction au reseau informatique
Chapitre I. introduction au reseau informatiqueChapitre I. introduction au reseau informatique
Chapitre I. introduction au reseau informatique
 
PFE régulateur de vitesse d'un moteur DC
PFE régulateur de vitesse d'un moteur DCPFE régulateur de vitesse d'un moteur DC
PFE régulateur de vitesse d'un moteur DC
 
Automatisation d'une maison intelligente via une application android
Automatisation d'une maison intelligente via une application androidAutomatisation d'une maison intelligente via une application android
Automatisation d'une maison intelligente via une application android
 
Etude d'installation électrique et réalisation de l'armoire électrique TGBT
Etude d'installation électrique et réalisation de l'armoire électrique TGBTEtude d'installation électrique et réalisation de l'armoire électrique TGBT
Etude d'installation électrique et réalisation de l'armoire électrique TGBT
 
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdf
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdfRapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdf
Rapport de stage Genie Logiciel TCHINDA JOEL Encadreur - Kamleu Noumi Emeric.pdf
 
Le grand livre d'Arduino pdf
Le grand livre d'Arduino pdfLe grand livre d'Arduino pdf
Le grand livre d'Arduino pdf
 
Télécharger livre - schéma d'installation électrique
Télécharger livre - schéma d'installation électriqueTélécharger livre - schéma d'installation électrique
Télécharger livre - schéma d'installation électrique
 
Alfabeto di arduino - lezione 4
Alfabeto di arduino - lezione 4Alfabeto di arduino - lezione 4
Alfabeto di arduino - lezione 4
 
05c reseaux-sans-fil
05c reseaux-sans-fil05c reseaux-sans-fil
05c reseaux-sans-fil
 

En vedette

Programming with sensors bumper switch 3
Programming with sensors   bumper switch 3Programming with sensors   bumper switch 3
Programming with sensors bumper switch 3David Young
 
Programming with sensors bumper switch 2
Programming with sensors   bumper switch 2Programming with sensors   bumper switch 2
Programming with sensors bumper switch 2David Young
 
1.5 projectile motion
1.5    projectile motion1.5    projectile motion
1.5 projectile motionDavid Young
 
kls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatkls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatNovii Kanadia
 
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...ecommerce poland expo
 
Iman bysajib hossain akash-01725-340978.
Iman bysajib hossain akash-01725-340978.Iman bysajib hossain akash-01725-340978.
Iman bysajib hossain akash-01725-340978.Sajib Hossain Akash
 
Top 8 chief business development officer resume samples
Top 8 chief business development officer resume samplesTop 8 chief business development officer resume samples
Top 8 chief business development officer resume samplesporichfergu
 
Yliko pake geniko_meros_201105.20-27
Yliko pake geniko_meros_201105.20-27Yliko pake geniko_meros_201105.20-27
Yliko pake geniko_meros_201105.20-27Nikos Kaklamanos
 
Sweden Presetasion
Sweden PresetasionSweden Presetasion
Sweden Presetasionoldusel
 
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a CometDDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a CometRichard Banks
 
Earned value management lecture 2009e my31
Earned value management lecture 2009e my31Earned value management lecture 2009e my31
Earned value management lecture 2009e my31rongo620
 
ニコニコ動画でのHTML5
ニコニコ動画でのHTML5ニコニコ動画でのHTML5
ニコニコ動画でのHTML5Sho KUSANO
 
Technological applications and innovations
Technological applications and innovationsTechnological applications and innovations
Technological applications and innovationsrbulalakaw
 
The Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - EmmaThe Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - Emmaregacylady
 
Business is fun: Shopping in madrid
Business is fun: Shopping in madridBusiness is fun: Shopping in madrid
Business is fun: Shopping in madridsarasacristan
 

En vedette (20)

Programming with sensors bumper switch 3
Programming with sensors   bumper switch 3Programming with sensors   bumper switch 3
Programming with sensors bumper switch 3
 
Programming with sensors bumper switch 2
Programming with sensors   bumper switch 2Programming with sensors   bumper switch 2
Programming with sensors bumper switch 2
 
1.5 projectile motion
1.5    projectile motion1.5    projectile motion
1.5 projectile motion
 
Intro to RobotC
Intro to RobotCIntro to RobotC
Intro to RobotC
 
Uso del scr
Uso del scrUso del scr
Uso del scr
 
kls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakatkls xii : Bab iii pers dlm masyarakat
kls xii : Bab iii pers dlm masyarakat
 
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
II Kongres eHandlu: Piotr Chmielewski, Social Media Now - "Kampanie reklamowe...
 
Iman bysajib hossain akash-01725-340978.
Iman bysajib hossain akash-01725-340978.Iman bysajib hossain akash-01725-340978.
Iman bysajib hossain akash-01725-340978.
 
Top 8 chief business development officer resume samples
Top 8 chief business development officer resume samplesTop 8 chief business development officer resume samples
Top 8 chief business development officer resume samples
 
Yliko pake geniko_meros_201105.20-27
Yliko pake geniko_meros_201105.20-27Yliko pake geniko_meros_201105.20-27
Yliko pake geniko_meros_201105.20-27
 
Shi20396 ch04
Shi20396 ch04Shi20396 ch04
Shi20396 ch04
 
Sweden Presetasion
Sweden PresetasionSweden Presetasion
Sweden Presetasion
 
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a CometDDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
DDD Sydney 2011 - Getting out of Sync with IIS and Riding a Comet
 
Earned value management lecture 2009e my31
Earned value management lecture 2009e my31Earned value management lecture 2009e my31
Earned value management lecture 2009e my31
 
2nd Easter A(2)
2nd Easter A(2)2nd Easter A(2)
2nd Easter A(2)
 
ASI Financials 2011 Brochure
ASI Financials 2011 BrochureASI Financials 2011 Brochure
ASI Financials 2011 Brochure
 
ニコニコ動画でのHTML5
ニコニコ動画でのHTML5ニコニコ動画でのHTML5
ニコニコ動画でのHTML5
 
Technological applications and innovations
Technological applications and innovationsTechnological applications and innovations
Technological applications and innovations
 
The Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - EmmaThe Regacy Chapter 5.4b Ink - Emma
The Regacy Chapter 5.4b Ink - Emma
 
Business is fun: Shopping in madrid
Business is fun: Shopping in madridBusiness is fun: Shopping in madrid
Business is fun: Shopping in madrid
 

Plus de David Young

1.4 acceleration
1.4   acceleration1.4   acceleration
1.4 accelerationDavid Young
 
1.2 displacement and position vs time graphs
1.2   displacement and position vs time graphs1.2   displacement and position vs time graphs
1.2 displacement and position vs time graphsDavid Young
 
2016 topic 5.2 hess's law
2016   topic 5.2  hess's law2016   topic 5.2  hess's law
2016 topic 5.2 hess's lawDavid Young
 
2016 topic 5.1 measuring energy changes
2016   topic 5.1 measuring energy changes2016   topic 5.1 measuring energy changes
2016 topic 5.1 measuring energy changesDavid Young
 
2016 topic 4.5 bonding - metallic
2016   topic 4.5 bonding - metallic2016   topic 4.5 bonding - metallic
2016 topic 4.5 bonding - metallicDavid Young
 
2016 topic 4.1 bonding - ionic
2016   topic 4.1 bonding - ionic2016   topic 4.1 bonding - ionic
2016 topic 4.1 bonding - ionicDavid Young
 
2016 topic 4.2 bonding - covalent
2016   topic 4.2  bonding - covalent2016   topic 4.2  bonding - covalent
2016 topic 4.2 bonding - covalentDavid Young
 
Unit 4 2014 ppt sound
Unit 4 2014  ppt    soundUnit 4 2014  ppt    sound
Unit 4 2014 ppt soundDavid Young
 
Unit 4 2014 ppt wave characteristics
Unit 4 2014  ppt    wave characteristicsUnit 4 2014  ppt    wave characteristics
Unit 4 2014 ppt wave characteristicsDavid Young
 
2016 topic 01 part 1
2016 topic 01   part 12016 topic 01   part 1
2016 topic 01 part 1David Young
 
Chemistry 1 - Atomic Structure
Chemistry 1 - Atomic StructureChemistry 1 - Atomic Structure
Chemistry 1 - Atomic StructureDavid Young
 
2016 Topic 2: Electron Configuration
2016  Topic 2: Electron Configuration2016  Topic 2: Electron Configuration
2016 Topic 2: Electron ConfigurationDavid Young
 
2016 Topic 2: Atomic Structure
2016 Topic 2: Atomic Structure2016 Topic 2: Atomic Structure
2016 Topic 2: Atomic StructureDavid Young
 
2016 topic 0 - oxidation and reduction (INTRODUCTION)
2016   topic 0 - oxidation and reduction (INTRODUCTION)2016   topic 0 - oxidation and reduction (INTRODUCTION)
2016 topic 0 - oxidation and reduction (INTRODUCTION)David Young
 
2016 topic 0 - elements & periodic table
2016   topic 0 - elements & periodic table2016   topic 0 - elements & periodic table
2016 topic 0 - elements & periodic tableDavid Young
 
Introduction to elements & periodic table
Introduction to elements & periodic tableIntroduction to elements & periodic table
Introduction to elements & periodic tableDavid Young
 
Physics ii djy 2013 ppt wave characteristics
Physics ii djy 2013 ppt    wave characteristicsPhysics ii djy 2013 ppt    wave characteristics
Physics ii djy 2013 ppt wave characteristicsDavid Young
 
Topic 20 6 stereoisomers
Topic 20 6   stereoisomersTopic 20 6   stereoisomers
Topic 20 6 stereoisomersDavid Young
 

Plus de David Young (20)

1.4 acceleration
1.4   acceleration1.4   acceleration
1.4 acceleration
 
1.3 velocity
1.3   velocity1.3   velocity
1.3 velocity
 
1.2 displacement and position vs time graphs
1.2   displacement and position vs time graphs1.2   displacement and position vs time graphs
1.2 displacement and position vs time graphs
 
1.1 vectors
1.1   vectors1.1   vectors
1.1 vectors
 
2016 topic 5.2 hess's law
2016   topic 5.2  hess's law2016   topic 5.2  hess's law
2016 topic 5.2 hess's law
 
2016 topic 5.1 measuring energy changes
2016   topic 5.1 measuring energy changes2016   topic 5.1 measuring energy changes
2016 topic 5.1 measuring energy changes
 
2016 topic 4.5 bonding - metallic
2016   topic 4.5 bonding - metallic2016   topic 4.5 bonding - metallic
2016 topic 4.5 bonding - metallic
 
2016 topic 4.1 bonding - ionic
2016   topic 4.1 bonding - ionic2016   topic 4.1 bonding - ionic
2016 topic 4.1 bonding - ionic
 
2016 topic 4.2 bonding - covalent
2016   topic 4.2  bonding - covalent2016   topic 4.2  bonding - covalent
2016 topic 4.2 bonding - covalent
 
Unit 4 2014 ppt sound
Unit 4 2014  ppt    soundUnit 4 2014  ppt    sound
Unit 4 2014 ppt sound
 
Unit 4 2014 ppt wave characteristics
Unit 4 2014  ppt    wave characteristicsUnit 4 2014  ppt    wave characteristics
Unit 4 2014 ppt wave characteristics
 
2016 topic 01 part 1
2016 topic 01   part 12016 topic 01   part 1
2016 topic 01 part 1
 
Chemistry 1 - Atomic Structure
Chemistry 1 - Atomic StructureChemistry 1 - Atomic Structure
Chemistry 1 - Atomic Structure
 
2016 Topic 2: Electron Configuration
2016  Topic 2: Electron Configuration2016  Topic 2: Electron Configuration
2016 Topic 2: Electron Configuration
 
2016 Topic 2: Atomic Structure
2016 Topic 2: Atomic Structure2016 Topic 2: Atomic Structure
2016 Topic 2: Atomic Structure
 
2016 topic 0 - oxidation and reduction (INTRODUCTION)
2016   topic 0 - oxidation and reduction (INTRODUCTION)2016   topic 0 - oxidation and reduction (INTRODUCTION)
2016 topic 0 - oxidation and reduction (INTRODUCTION)
 
2016 topic 0 - elements & periodic table
2016   topic 0 - elements & periodic table2016   topic 0 - elements & periodic table
2016 topic 0 - elements & periodic table
 
Introduction to elements & periodic table
Introduction to elements & periodic tableIntroduction to elements & periodic table
Introduction to elements & periodic table
 
Physics ii djy 2013 ppt wave characteristics
Physics ii djy 2013 ppt    wave characteristicsPhysics ii djy 2013 ppt    wave characteristics
Physics ii djy 2013 ppt wave characteristics
 
Topic 20 6 stereoisomers
Topic 20 6   stereoisomersTopic 20 6   stereoisomers
Topic 20 6 stereoisomers
 

Programming with sensors bumper switch 1

  • 1. VEX Robotics I Power Points Topic 09 Programming Design Basics Bumper Switch Sensing 1 www.pedagogics.ca
  • 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. Bumper Switch (digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 0
  • 4. Bumper Switch (digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 1
  • 5. Bumper Switch (digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 0
  • 6. Bumper Switch (digital sensor) Usually positioned on front of robot. Output is either a 1 (depressed) or a 0 1
  • 7. Program sketch #1 Write a simple program to make your robot drive forward indefinitely , but will stop, turn 180o and continue driving if the robot encounters an obstacle. STEP 1 – FLOWCHART • thinking about how ROBOTC works STEP 2 – PSEUDOCODE STEP 3 – ACTUAL CODE
  • 9. START Flow chart describes behavior sequence. DRIVE FORWARD This flowchart gives us the basic NO 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. 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 FORWARD Move on loop ? FALSE END Stop, reverse, 180 degree turn
  • 11. DECISIONS must This type of question is called a Boolean be thought of as statement. questions that can 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
  • 13. START Pseudo code - basic commands, comments about functions and behaviors This code will never compile Forms the backbone of your program and translates from the flowchart to ROBOTC
  • 14.
  • 15. IF , ELSE boolean statement used to check bumper switch. If switch is not pressed, robot START drives forward IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARD loop ?
  • 16.
  • 17. IF , ELSE boolean statement used to check START bumper switch. If switch is not pressed, robot drives forward IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARD loop ?
  • 18.
  • 19. If switch is pressed – ELSE – the stop and turn START behavior occurs, then robot returns to moving forward (unless what is happening?) IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARD loop ? FALSE Stop, reverse, 180 degree turn
  • 20.
  • 21. START IF Always Switch TRUE WHILE DRIVE not LOOP ? infinite pressed FORWARD Move on loop ? FALSE END Stop, reverse, 180 degree turn