dr. gary stewardson, raymond boyles hello again, sparkey here. slippery and i will help you explore...

Post on 16-Dec-2015

215 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Dr. Gary Stewardson, Raymond Boyles

Hello again, Sparkey here. Slippery and I will help you explore how to create a program that simulates outputs on a traffic light. Make sure you have your guided notes.

1

Flowcharts

Dr. Gary Stewardson, Raymond Boyles

Flowcharts can be a useful tool that better enable us to organize, problem solve, and brainstorm when we are writing a program. Flowcharts are similar to thinking maps and concept maps we use to organize, problem solve, and brainstorm when we are writing a paper.

Flowcharts

2

Dr. Gary Stewardson, Raymond Boyles

In our last program, we wrote a program to turn on a light for two seconds. Let’s use symbols to represent the logical flow of this program.

Flowcharts

3

Dr. Gary Stewardson, Raymond Boyles

Symbols

Start and Stop symbols represent the beginning or end of a program. These symbols are simply a place holder and are oval.

4

Dr. Gary Stewardson, Raymond Boyles

Input and outputs from the computer can be represented by the parallelogram symbol below. We use this symbol to represent when we turned the light on.

5

Symbols

Dr. Gary Stewardson, Raymond Boyles

Symbols

We can also use this symbol to represent a switch or a touch sensor.

6

Dr. Gary Stewardson, Raymond Boyles

Symbols

Process symbols represent computational action as rectangles or blocks and represent “Action”. For example, we use this symbol to represent the timer counting two seconds.

7

Dr. Gary Stewardson, Raymond Boyles

Symbols

The decision symbol represents a yes/no and is in the shape of a diamond. We use this symbols to represent testing if the counter has counted to two.

8

Dr. Gary Stewardson, Raymond Boyles

Symbols

The decision symbol can also represent if a switch or a touch sensor is pushed or not.

9

Dr. Gary Stewardson, Raymond Boyles

Symbols

The arrow symbols represent the direction of flow in a program. The arrow symbols shows how the logic flows in a computer program.

10

Dr. Gary Stewardson, Raymond Boyles

Complete Flowchart

The connection of all the symbols shows a process. The flowchart to the right represents the process of turning a light on for two seconds, then turning off the light, and then ending the program.

11

Dr. Gary Stewardson, Raymond Boyles

Complete Flowchart

1. Start the process

2. Turn on the light

3. - If (Yes) the time has expired then: Go to Stop- If (No) the time has not expired then keep counting

4. Turn off the light

5. Stop

12

Dr. Gary Stewardson, Raymond Boyles

Flow Chart Activity

Our next program will perform the following so please write these down in your activity guided notes:

• The green light and red light will turn on for two seconds.

• The green and red light will turn off.

• The green and yellow light will turn on for one second

• The green and yellow light will turn off 13

Dr. Gary Stewardson, Raymond Boyles

Flow Chart Activity

Wiring:

• The green light is connected to Port A of the NXT controller and relay 1 on the relay board.

• The yellow light is connected to Port B of the NXT controller and relay 2 on the relay board

• The red light is connected to Port C of the NXT controller and relay 3 on the relay board

14

Dr. Gary Stewardson, Raymond Boyles

Pre-Programming Activity

With the symbols below and the PowerPoint guided notes, create a flow chart that represents a computer program that will logically follow the steps you have just written in your Activity 10 guided notes.

15

Dr. Gary Stewardson, Raymond Boyles

Flow Chart

16

Your flow chart should look something like the flowchart pictured to the right.

Dr. Gary Stewardson, Raymond Boyles

Flow Chart

NXT Object Reference

17

Your computer program should look something like the flowchart pictured to the right.

Dr. Gary Stewardson, Raymond Boyles

Complete Flowchart

Can you flowchart the process of a traffic light?

18

Dr. Gary Stewardson, Raymond Boyles

Complete Flowchart

Now, let us complete Activity 10

19

top related