1 / 12

Introduction to Sensors

Introduction to Sensors. Your answers here!. What are sensors?. A sensor tells a robot one simple thing about it’s environment Temperature Distance Light intensity Allow robots to see and feel the physical world through which they travel Two main types of sensors: digital and analog.

leoma
Télécharger la présentation

Introduction to Sensors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Sensors

  2. Your answers here! What are sensors?

  3. A sensor tells a robot one simple thing about it’s environment Temperature Distance Light intensity Allow robots to see and feel the physical world through which they travel Two main types of sensors: digital and analog What are sensors?

  4. Can provide a range of feedback The robot will interpret feedback from the sensor as a number from 0 to a pre-defined maximum (1024 for most Vex sensors) A light sensor has many states: If it is very bright, the sensor will return a number close to 30 If it is very dark, the sensor will return a number close to 1000 Analog Sensors

  5. Can distinguish between two different “states” The meaning of the states depends on the sensor A bumper sensor has two “states” If it is pressed, it is a 0 If it is not pressed, it is a 1 Digital Sensors

  6. A value-holding “container” with a label You can retrieve the value in this “container” when it is needed There are different types of values you can store in variables. You will use the “int” type, which allows you to store any whole number from 0 to a large number (positive or negative) You can assign a starting value to your variable which will store that value at the start of the program Variables

  7. Open the project “BUMPERTEST.ECP” Download it to your robot and open the terminal window Bump Sensor Introduction

  8. Comments - allows you to leave notes to yourself and others about your code The compiler ignores comments Understanding bump sensor code

  9. While Loop – block of code that repeats itself as long as the condition inside the parenthesis is true The == operator returns true if both sides are equal, and false if they are not equal In our code loop will always equal 1, so this loop will run forever Understanding bump sensor code

  10. Bumper sensor – stores the value of the digital input 6 to the variable “bumper” Now the robot knows if the bump sensor is being pressed in (0) or not (1) Understanding bump sensor code

  11. Print to screen – displays information in the terminal window This particular code displays the value of the bump sensor Understanding bump sensor code For now, make sure your settings are as follows: * Variable: the variable you want to display * Message: the message with the variable * Directive: %d * Type-cast: int

  12. We are going to write a program that runs one motor until a bump sensor is pressed in Begin by opening easyC Writing your own code

More Related