Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to VEX IQ Programming with Modkit

Similar presentations


Presentation on theme: "An Introduction to VEX IQ Programming with Modkit"— Presentation transcript:

1 An Introduction to VEX IQ Programming with Modkit
Robotics Lesson Materials: VEX IQ sensor car (per 2 students) Computer running Modkit (per 2 students) An Introduction to VEX IQ Programming with Modkit Lesson 06

2 Programming task: Count to 10
Remind the students of the variable blocks: we can give a variable any name we like and store a value in there (such as white=30). So far we haven’t changed this value during our program, but we can. So let’s create a simple counter program. We also want to display this changing value, so we’ll use the VEX IQ brain LCD screen to show the user of our program the changing value of our counter. This slide shows most of the blocks we’ll use. Have the students identify and explain the blocks they know, can they guess the function of the new blocks? (Guide and correct where needed).

3 Programming task: Count to 10
Show the students where they can find the new ‘brain’ blocks in the Modkit interface.

4 Programming task: Count to 10
Challenge You need to program the robot to…. Clear the LCD display on the brain Count up from 1 to 10, waiting 2 seconds between each step. Show the continuous count on the LCD of the brain. As there are no sensors used in this programming exercise, nothing needs adding or configuring in the robot view of Modkit. The whole program will be in the brain section of the blocks view. The students should be able to piece the skeleton (see next slide) of the program together.

5 Programming task: Count to 10
Guide the students with pseudo code on how the program would count: check what the current value of our variable is, add one and put it in the same variable. Try to let them put the pieces together while providing them with the needed blocks. Notice how we can drop the ‘MyCounter’ block in the print block. Just like the Black and White blocks represented values in our previous programs, this MyCounter block will be whatever number our counter will be at that time. Guide or let students complete the program. (Next slide shows full program)

6 Programming task: Count to 10
Please note there are various equally correct ways to program this.

7 Automated vehicles Remember how it all started with our Google car? Slightly easier but very similar automated vehicles are already in use in airports throughout the world. Terminal 5 at Heathrow airport has a ‘Pod Parking’. If you park your car there, you can take a fully automated vehicle from the parking to the terminal and back again. Have a look at the clip (01:10)

8 Programming task: Robot car
Final Challenge You need to program the robot car to…. Warn your passengers with an orange LED light that the car is about to move (3 seconds warning). Your car will move forward until it is 25 cm away from a wall, while driving the LED should be white. Once the car reaches the wall, it should stop, change its light to green and allow the passengers 5 seconds to (dis)embark. After a 3 second warning, by changing the light to orange, the car will turn around (how many degrees would that be?) while a red light is shown and go back to the start position (with a white LED light). Repeat the same instructions when reaching this wall. The car should show how many trips it makes on the LCD display of the brain. We will try to recreate a program that mimics these Heathrow ‘Pods’. In the first challenge the students will program their car to drive forward until the car is 25 cm away from a wall. Once there, the car will give the passengers some time to get in and out, warn them that the car is ready to turn around, turn around and go back to the start point. Apart from visual feedback clues to the passenger (green light when boarding, orange when the car is about to move again, white while driving forward and red when turning around), we will also use a variable to keep track of the number of trips the car has made. Please note there is one new block in this exercise (the ‘break’ block to exit a forever loop), all the other blocks and programing principles have been used before. Students should be allowed to refer back to previous programs while programming this task.

9 Programming task: Robot car
Although it might seem a bit daunting at first, the students already have the needed knowledge to complete this task. Let’s guide them though creating the program, making sure you allow them the needed time to figure it out before showing the next step. We start in the robot view and will need the following parts: Drivetrain, Touch LED, Distance Sensor. In the extension we will use the ‘color’ sensor to follow a track (as in Lesson 5) instead of the easier straight lines of this exercise. Make sure you double check the ports of the sensors and make sure your drivetrain settings are correct (Connected wheels etc.)

10 Programming task: Robot car
We start with a simple ‘getting ready’ broadcast: we need the Touch LED to glow orange, we can set the speed and turning speed for our drive train (more important in the line tracking version of the program) and don’t forget our distance sensor needs a maximum distance (see lesson 3).

11 Programming task: Robot car
The next part of the program will be the driving (after a 3 second wait). The brain will broadcast this command (called ‘followline’ in the example program) . What needs happen now? Which parts of the robot car need to respond and what do they need to do? Answers: DriveTrain (needs to start moving our car) and Touch LED (needs to change colour), once the destination is reached (25cm away from wall), the robot car needs to stop (drivetrain) and the light needs to go to green (Touch LED) for 5 seconds. The program is revealed in the next slide, try to gently guide the students to the right code instead of revealing the solution. Please note that in the example program the colour change is called from the drivetrain blocks instead of the brain (both are correct), the reason is to keep the subroutine names easy to follow (MakeGreen, MakeOrange, MakeWhite,… to change the colour of the LED). We will add the needed counter after the next slide.

12 Programming task: Robot car
Note how a forever loop is used, once we are too close to a wall (see lesson 3), we need to ‘break out’ of this loop, using the ‘Break’ block. Another solution would be to use a while loop instead of a forever loop (which the students should have been able to correctly implement since lesson 3). This shows how a programming challenge can have multiple solutions that all result in the same output. Ask the students to add our counter to the drivetrain: we need to count our number of trips and display this on the LCD screen of the brain. (see start of the lesson, show previous program if needed). After adding the counter we can add the next part: our light needs to go to orange for 3 seconds, then the car needs to turn around. We will use a separate algorithm for turning (to keep the code easy to understand), so make sure the broadcast command is used. (Program in next slide).

13 Programming task: Robot car
After waiting for 5 seconds, the light needs to become orange for 3 seconds. Next our car needs to turn around (use new broadcast command for this) while making the LED red. Finally we need a 3 second wait with an orange light followed by the next trip of our car (we already programmed this, so we can just call our routine back with a broadcast command). Try to gently guide the students to program these parts, they should be able to add these bit on their own. (solution on next slide).

14 Programming task: Robot car
Allow some time for students to test their programs and debug if needed. Note: Stopping at 25cm with a 20% speed is a safe option. If there is time, allow the students to experiment with these values. (The slower the car drives the shorter the ‘breaking’ distance can be and the more accurate our turn.) If there is time left, or as an extension, this program can be adapted to follow a track up to a wall and follow the same track back. The next slide will show this program (also provided as RobotCarFinal-0.mk4v). Only the Drivetrain ‘Followline’ routine will change, the only part shown is the part that changed. Don’t forget to add the ‘color’ sensor in the robot view. The algorithm is identical to the one for lesson 5, so the students should be able to complete this task (possibly with notes from lesson 5).

15 Programming task: Robot car
Please note that the black track leading up to a wall should be long enough for the car to turn 180 degrees and find the track back! (set the breaking distance to 100mm or even slightly less to make this as short as possible.

16 Automated Vehicles Open discussion. Guide the students to discuss where automated vehicles will be first seen and how this can change our way of life. Discuss how close their car came to a real life solution.

17 Summary Today you have: Revisited all your programming skills.
Learning objective: Combining all the programming skills and using all the covered sensors, build an autonomous car. Extend our knowledge of variables. Today you have: Revisited all your programming skills. Learned more on how to work with variables. Programmed a robot car for a real life situation. Send the program to a robot, test and debug your code.


Download ppt "An Introduction to VEX IQ Programming with Modkit"

Similar presentations


Ads by Google