In this chapter, we learn to
use input buttons to interact with Thonny’s console.
use a piezo buzzer to produce sound.
Introduction: Button and Buzzer.
AI Task #1: Print "A" when button A is pressed and "B" when button B is pressed.
AI Task #2: Make the buzzer play a short melody of "Twinkle Twinkle Little Star".
Activities: Build a water drinking reminder.
Challenge: Program drinking reminder to accept user input for the duration.
Buttons are essential electronic components in modern technology that allow us to input commands and interact with various devices. They come in all shapes and sizes, from the tiny buttons on your calculator to the larger ones on your computer keyboard.
-> Libraries: board, time, digitalio.
-> Button Configuration: Button A (Yellow) to GP0 as digital input.
Upon completion of the activity, you should be able to:
-> Press Button A and output "Button A is pressed" will be displayed at the shell console.
-> Click here to download code.
Task:
-> Print "A" when button A is pressed and "B" when button B is pressed.
Upon completion of the activity, you should be able to:
-> See "A" is printed in the shell console when Button A is pressed, and "B" is printed on the shell console when Button B is pressed.
Want to make some noise with your EDU PICOV2? In this section, you will learn how to activate your EDU PICO V2 built-in piezo buzzer. While you're at it, go ahead and hook up the EDU PICO V2 to a headset or a speaker at the buzzer module too!
-> Libraries: board, simpleio.
-> Audio / Buzzer Configuration: Buzzer to GP21.
-> Action Required: Flip the buzzer module switch downwards to enable buzzer output.
Upon completion of the activity, you should be able to:
-> Execute the code and EDU PICO V2 buzzer module will continuously beep at a 2 seconds interval with a frequency of 440Hz.
-> Click here to download code.
Task:
-> Make the buzzer play a short melody of "Twinkle Twinkle Little Star ".
Upon completion of the activity, you should be able to:
-> Hear the buzzer plays the "Twinkle Twinkle Little Star " melody once when the program starts.
Let's build a water drinking reminder with EDU PICO V2! Don't worry, we will keep your first project simple. Ultimately, you will learn how to combine codes from multiple components. Let's Go!
In the original code, the timer runs for only 5 seconds by default. In this challenge, you are required to modify the code to allow the user to customize the duration of the water-drinking reminder!
-> Libraries: board, digitalio, time, simpleio.
-> Button Configuration: Button A (Yellow) = GP0, Button B (Blue) = GP1.
-> Input:
Press Button A to activate the 5 second (default) countdown.
Press Button B to reset the buzzer.
-> Libraries: board, digitalio, time, simpleio.
-> Button Configuration: Button A (Yellow) = GP0, Button B (Blue) = GP1.
Upon completion of the activity, you should be able to:
-> Execute the code and the buzzer will start beeping once the countdown reaches zero.
-> The program will print the reminder text and timer status to the user at the shell console.
Upon completion of the activity, you should be able to:
-> Execute the program and manually set the reminder duration.
-> The buzzer will start beeping once the countdown reaches zero.
-> The program will print the reminder text and timer status to the user at the shell console.