Presentation is loading. Please wait.

Presentation is loading. Please wait.

RobotC Sensors.

Similar presentations


Presentation on theme: "RobotC Sensors."— Presentation transcript:

1 RobotC Sensors

2 Learning Objectives Take a look at some of the options for VEX Sensors
Be able to configure sensors Be able to use a touch sensor/limit switch Be able to use the Ultrasonic Sensor to drive forward until you are near an object Be able to use light sensors to track a line

3 Sensor Ports Analog Ports 1-8 Light Sensor
Line Tracking Potentiometer Accelerometer UART (Universal Asynchronous Receiver/Transmitter) Ports 1, 2 I2C Inter-integrated Circuit Protocol Allows several devices to be chained to one port. Digital Ports 1-12 Touch Sensors Limit Switch Bumper Switch Motor Encoder Ultrasonic Range Finder Speaker

4 Digital: Bumper Switch
Senses when it is pushed 0 == not pushed false == not pushed 1 == pushed true == pushed

5 Sensor Setup 1) VEX Cortex Digital Sensors 1-12
3) Use the pull down menu to select the ‘Touch’ sensor. The ‘Touch’ sensor is used for the Bumper Switch and the Limit Switch. 2) Select the Port and name the sensor. Name: Start with a letter, no spaces, punctuation or reserved words. Describes the sensor 4) Click on ‘Apply’ the ‘OK’

6 Getting the Reading SensorValue(frontBumper);

7 Challenge Create a Bug Robot that will run forever, but when it hits something it will back up, turn and then keep on going. Use the Physical Robot or the Virtual Buggy bot on ‘Utility’ Huge Table challenge

8 PseudoCode Go forward Forever If I hit something Back up Turn
Start going forward

9 Possible Solution Extensions Put multiple touch sensors on the front
Add a touch sensor to the back and react when the back runs into something

10 Using the Limit Switch Can sense when arms reach their limit.
Can sense when the robot bumps into something. 0 or false when not pressed 1 or true when pressed

11 Configuring the Limit Switch
1) Select the Digital Sensors Tab Robot -> Motors and Sensors Setup 3) Use the pull-down menu to select Touch. 2) Name the Sensor frontLimit 4) Apply and OK.

12 Preventing the Arm From Lowering Too Far
Pseudo Code If the down button is pressed AND the limit switch is not pressed Go down AND? Remember the conjunctions?

13 Conjunctions Conditions can be combined using conjunctions && (AND)
while ((SensorValue[rightEncoder]<1800) && (SensorValue[leftEncoder] <1800)) { //while both encoders are less than 1800 it will repeat the code in the {} block } || (OR) while ((SensorValue[rightEncoder]<1800) || (SensorValue[leftEncoder] <1800)) { // While either the leftEncoder<1800 or the rightEncoder is <1800 it will //repeat the code inside the {} block ! (NOT) Turns true to false and false to true while !(SensorValue(leftEncoder)>1800)

14 Putting it together Pseudo Code
Has the robot wait until button 7D is pressed Pseudo Code Uses a timer to limit the driving time If the down button is pressed AND the limit switch is not pressed Go down Reduces the power to the motors to ½ the value from the remote Button 6U is for having the arm go up. If button 6D is pushed and the Limit Switch is not pushed. If no button is pushed OR 6Down is pushed and the limit switch is pushed.

15 Putting it together Virtual World
Pseudo Code If the down button is pressed AND the limit switch is not pressed Go down The && can only combine two complete conditions.

16 Challenges Minefield Challenge Incorporate Limit Switch Extension
Squarebot: Virtual World Your bot : Real World Incorporate Limit Switch Extension Incorporate a Potentiometer to provide more control Information on the Potentiometer on the next slide

17 Extension: Using the Potentiometer to Limit
Go to And follow the video trainer lesson


Download ppt "RobotC Sensors."

Similar presentations


Ads by Google