Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson 3 Sub-Routines.

Similar presentations


Presentation on theme: "Lesson 3 Sub-Routines."— Presentation transcript:

1 Lesson 3 Sub-Routines

2 Lesson Objectives To understand how to use values to control systems
To understand what sub routines are, and how they are used to make control technology more efficient.

3 It has 4 inputs. 3 buttons and a dial
Task 1: Mobile This mimic is a child's cot mobile. It has 4 inputs. 3 buttons and a dial It has 6 outputs. A motor which turns the mobile, and 5 lights/motors on each vehicle

4 Values At the top of a mobile is a dial. We can set it to different values from 0 to 100 which increment by 5 each time How might we use this dial? What could we use it to control?

5 Values We can speed up the motor depending on the value of the dial above it.

6 Task 1: Create a flow diagram so that the motor goes forward at 20% when the value is equal to 10

7 Task 2: Make the motor turn faster as the value increases.

8 Task 3: Add 3 further flow diagram to program what will happen when the 3 buttons are pressed. Remember there are several more outputs that you can include.

9 These flow charts are used the control a railway crossing barrier.
Start Start Start Start Train from track 1? Train from track 2? Train from track 3? Train from track 4? These flow charts are used the control a railway crossing barrier. Light on Light on Light on Light on Light off Light off Light off Light off Light on Light on Light on Light on They all makes the lights flash before they close the barrier. Why is it inefficient to write the same command 4 times? Light off Light off Light off Light off Close Barrier 1 Close Barrier 2 Close Barrier 3 Close Barrier 4

10 Extension: Sub Routines
Sub routines are used when the same flow chart is being used several times.

11 Start Start Start SUB FLASH They work like this Train from track 1? Train from track 2? Train from track 3? Light on Light off SUB FLASH SUB FLASH SUB FLASH Light on Close Barrier 1 Close Barrier 2 Close Barrier 3 Light off Each of the flow charts now includes a sub routine. This makes the flow chart more efficient. It saves time for the programmer and the computer. Stop

12 Sub routines in the mobile
Create a sub routine to program the lights and motors on the vehicles.

13


Download ppt "Lesson 3 Sub-Routines."

Similar presentations


Ads by Google