Presentation is loading. Please wait.

Presentation is loading. Please wait.

Automation with RobotC

Similar presentations


Presentation on theme: "Automation with RobotC"— Presentation transcript:

1 Automation with RobotC
Starting to write and troubleshoot computer code Log in to your computer and… Open 

2 Know your switches! Photo Sensor Name Abbreviation limitSwitch Dgtl1
bumpSwitch Dgtl2 lineFollower or lineTracker In1 Potentiometer In2

3 Analog Switches The Potentiometer and Line Tracker work on a scale of 0 – 4095 POTENTIOMETER LINE TRACKER

4 Potentiometer The Potentiometer works on a scale of 0 – 4095
It is very sensitive, and it is NOT meant to turn all the way around, so please don’t force it!

5 Potentiometer Position = a number between 0 and 4095
sensorPort = in2 or potentiometer

6 Analog Switches Write a code for the potentiometer that turns on a motor for 3 seconds when you turn it past 3500 POTENTIOMETER

7 Potentiometer Program Hint
task main() { untilPotentiometerGreaterThan(position, sensorPort); }

8 Potentiometer Position = a number between 0 and 4095
sensorPort = in2 or potentiometer

9 Potentiometer Program Hint
task main() { untilPotentiometerGreaterThan(3500, in2); }

10 Potentiometer Program Answer
task main() { untilPotentiometerGreaterThan(3500, in2); startMotor(rightMotor, 127); wait(3); stopMotor(rightMotor); }

11 ROBOTC Debugger When I write a code with a potentiometer, I need to see what the sensor is reading right now. We do this by looking at a “Debugger” window.

12 ROBOTC Debugger After you click on “Download to Robot”, open the Sensor Debug window by going to Robot > Debug Windows > Sensors

13 The Claw!!!!!!!!!!!!!!!! Now….Write a program that uses the potentometer to open and close the claw

14 clawMotor runs for 1.5 seconds
Claw Specifics Claw speed = 35 clawMotor runs for 1.5 seconds Open when Poten >3500 Close when Poten < How do we make motors run in opposite directions?

15 Specific Instructions
OPEN: When you turn the Potentiometer past 3500, start the claw motor, wait 1.5 seconds, stop the claw motor. CLOSE: When you turn the Potentiometer under 1500, start the claw motor, wait 1.5 seconds, stop the claw motor.

16 Claw Program answer

17 RobotC Warm-up Open up RobotC Open a New page
Go to Motors and Sensors and choose the GTT Testbed POTENTIOMETER

18 A Malfunction with the Claw Machine…
There is a problem with the claw machine at your local Chuck E Cheese, and you have been called to fix it.

19 Claw Repair It seems that the claw opens whenever a button is pressed, but never closes again, and many children have shed tears over their lost toys.

20 Here is your starting program

21 Here is your starting program
Please copy this part of the program into a new file

22 Claw Repair 1. Your job is to use a potentiometer, and have the claw open when you turn it one way, and close when you turn it the other way 2. Save as “Claw Machine” when you are done.

23 Please fix the claw machine and make the children happy again
Claw Repair Please fix the claw machine and make the children happy again

24 Again…here are your instructions
1. Your job is to use a potentiometer, and have the claw open when you turn it one way, and close when you turn it the other way 2. Save as “Claw Machine” when you are done.

25 Open System An open system will let you run your program over and over without having to restart it.

26

27 Finish Testbed Practice programs
Today we will finish practice coding our testbeds… Please work with your table partner. One person log in, and another make sure you have a testbed.

28 Review - Open System

29 Line tracker Position = a number between 0 and 4095
sensorPort = in1 or lineTracker

30 Line tracker The line tracker senses light and dark.
Write a program that turns on a motor, and has it stop when you cover the line tracker with your finger.

31 Line tracker Program Answer
HINT: Use the “untilLight” command


Download ppt "Automation with RobotC"

Similar presentations


Ads by Google