+ All Categories
Home > Documents > E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf ·...

E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf ·...

Date post: 28-May-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
104
1 E11: Autonomous Vehicles Fall 2011 Harris & Harris PS 5: Reaction Timer and Light Tag In this assignment you will write two programs: one to test reaction times and the other to play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the phototransistor. You will also need a flashlight or other light source. Important: keep track of how long it takes for each program by placing the following comment on the first line of each program file (where xx is the number of hours that it took you). If you worked with a partner, list the average time it took you (if it took one person 3 hours, and the other 4 hours, the average is 3.5 hours). // Time to complete program = xx hours Part 1: Reaction Timer Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and distance sensor. You will play a note on the buzzer for a random length of time, switch the note, then time how long it takes to move your hand in reaction to the changed note. Create a program called ps5_1.pde that does the following: 1. To begin the game, the user puts his or her hand in front of the distance sensor. 2. Once your program detects the user’s hand, it begins to play a note for a random length of time between 300 and 3000 ms, then switches notes. 3. When the program switches notes, the user moves his or her hand away from the distance sensor (best is to move the hand up or down, out of range of the sensor). 4. The program times how long it takes between the note switch and the user moving his/her hand. 5. The program prints the reaction time to the Serial Monitor and waits for the user’s hand to be placed in front of the distance sensor to start the game again. Note: it is very easy to cheat and register a reaction time of 0. If the user simply places his or her hand in front of the distance sensor to start the first note and then removes it before that note is done playing the reaction time will be recorded as 0 milliseconds. You can ignore this case (none of your friends would cheat!)
Transcript
Page 1: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 2: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 3: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 4: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 5: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 6: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 7: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 8: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 9: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 10: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 11: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 12: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 13: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 14: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 15: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 16: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 17: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 18: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 19: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 20: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 21: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 22: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 23: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 24: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 25: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 26: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 27: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 28: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 29: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 30: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 31: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 32: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 33: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 34: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 35: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 36: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 37: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 38: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 39: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 40: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 41: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 42: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 43: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 44: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 45: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 46: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 47: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 48: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 49: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 50: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 51: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 52: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 53: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 54: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 55: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 56: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 57: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 58: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 59: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 60: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 61: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 62: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 63: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 64: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 65: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 66: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 67: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 68: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 69: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 70: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 71: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 72: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 73: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 74: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 75: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 76: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 77: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 78: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 79: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 80: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 81: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 82: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 83: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 84: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 85: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 86: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 87: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 88: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 89: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 90: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 91: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 92: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 93: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 94: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 95: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 96: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 97: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 98: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 99: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 100: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 101: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 102: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.

Page 103: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

1

E11: Autonomous Vehicles Fall 2011

Harris & Harris

PS 5: Reaction Timer and

Light Tag

In this assignment you will write two programs: one to test reaction times and the other to

play light tag. You will use two of your Mudduino’s sensors: the distance sensor and the

phototransistor. You will also need a flashlight or other light source. Important: keep

track of how long it takes for each program by placing the following comment on the first

line of each program file (where xx is the number of hours that it took you). If you

worked with a partner, list the average time it took you (if it took one person 3 hours, and

the other 4 hours, the average is 3.5 hours).

// Time to complete program = xx hours

Part 1: Reaction Timer

Your first assignment is to build a reaction timer game using the Mudduino’s buzzer and

distance sensor. You will play a note on the buzzer for a random length of time, switch

the note, then time how long it takes to move your hand in reaction to the changed note.

Create a program called ps5_1.pde that does the following:

1. To begin the game, the user puts his or her hand in front of the distance sensor.

2. Once your program detects the user’s hand, it begins to play a note for a random

length of time between 300 and 3000 ms, then switches notes.

3. When the program switches notes, the user moves his or her hand away from the

distance sensor (best is to move the hand up or down, out of range of the sensor).

4. The program times how long it takes between the note switch and the user moving

his/her hand.

5. The program prints the reaction time to the Serial Monitor and waits for the user’s

hand to be placed in front of the distance sensor to start the game again.

Note: it is very easy to cheat and register a reaction time of 0. If the user simply places

his or her hand in front of the distance sensor to start the first note and then removes it

before that note is done playing the reaction time will be recorded as 0 milliseconds. You

can ignore this case (none of your friends would cheat!)

Page 104: E11: Autonomous Vehicles - Harvey Mudd Collegepages.hmc.edu/harris/class/e11/fall11/ps5.pdf · Create a program called ps5_1.pde that does the following: 1. To begin the game, the

2

Part 2: Light Tag

Now you will play Light Tag using the phototransistor on your Mudduino. The

phototransistor detects light and converts the light level into a voltage. In addition to your

Mudduino, you will need a flashlight (or other light source) to complete this lab.

Create a program called ps5_2.pde that does the following:

1. The program should play a song to indicate that it is ready to play. (You can use

the song from problem set 2 if you want.)

2. The song continues to play until the phototransistor is “tagged” – i.e., detects the

light source.

3. The program plays a second song (can be a simple beeping – or could be

something more dramatic) to indicate that the Mudduino has been tagged.

4. After a short amount of time, the program plays the first song again, indicating

that it is again ready to play.

Deliverables

You are responsible for turning in 2 Arduino files:

• PS5_1.pde

• PS5_2.pde

Grading

Your score is based on the following:

5: Your program runs as expected; the code is clear and well commented.

4: Your program runs as expected; the code is mostly clear and well commented.

3: Your program runs as expected; more clarity and/or comments are needed.

2: Your program mostly runs as expected; clarity and comments are missing.

1: Your program does not run as expected; but the code is mostly clear and commented.

0: Your program does not run as expected; clarity and comments are lacking.


Recommended