Lesson Plan
Triggering The Box Using A Button & IR Sensor
In the final lesson, you’ll bring the project together by using both the button and IR sensor to trigger your Magic Box.
Tutorial Video
What You’ll Learn
- Combine multiple inputs in one program
- Use the button and IR sensor to control the box
- Test and improve the complete Magic Box system
Follow Along
- Follow the video to combine the button and IR sensor logic.
- Test each input separately.
- Test the complete box several times and troubleshoot any unreliable behavior.
- Once everything works, try changing the program to give your Magic Box a new behavior.
Check Your Work
Before moving on, make sure your project behaves like the example shown in the video. If something isn’t working, compare your wiring and code carefully with the video before changing multiple things at once.
What’s Next?
You’ve completed the Magic Box Workshop! Try one of the additional challenges below.
Additional Challenges
- Code your box to open half way with the button, but fully open with the IR sensor.
- Code your box to open ONLY if both the button and IR sensor are triggered at the same time.
- Code your box to open ONLY if you push the button for more than 1 second.
- Code your box to open only if you first press the button, then trigger the IR sensor in sequence.
- Make an arcade game!
- Place the IR sensor inside the box so it can detect whether an object is present. Put a small object inside the box, such as a rock.
- Program the button so that pressing it opens the box.
- Try to remove the object before the box closes. Use the IR sensor to detect when the object has been removed, and program the LEDs to flash when the player wins.
- Increase the difficulty after each successful round by reducing how long the box stays open.