|
156 | 156 | " pwmSpeaker.duty_u16(32768) # Set the duty cycle to 50% (half as loud as possible)\n", |
157 | 157 | " else: # If no key is pressed\n", |
158 | 158 | " pwmSpeaker.freq(0)\n", |
159 | | - " pwmSpeaker.duty_u16(0) # turn off the speaker " |
| 159 | + " pwmSpeaker.duty_u16(0) # turn off the speaker \n", |
| 160 | + "\n", |
| 161 | + "# Frequency Table: Feel free to change the frequencies for each button press to play different notes.\n", |
| 162 | + "# note frequency\n", |
| 163 | + "# c 262 Hz\n", |
| 164 | + "# d 294 Hz\n", |
| 165 | + "# e 330 Hz\n", |
| 166 | + "# f 349 Hz\n", |
| 167 | + "# g 392 Hz\n", |
| 168 | + "# a 440 Hz\n", |
| 169 | + "# b 494 Hz\n", |
| 170 | + "# C 523 Hz" |
160 | 171 | ] |
161 | 172 | }, |
162 | 173 | { |
163 | 174 | "cell_type": "markdown", |
164 | 175 | "id": "10d5c3fe-852f-42f7-8378-85dc8c8c7c3e", |
165 | 176 | "metadata": {}, |
166 | 177 | "source": [ |
| 178 | + "\n", |
167 | 179 | "## What You Should See\n", |
168 | 180 | "Different tones will play when you press different keys. Turning the potentiometer will adjust the volume.\n", |
169 | 181 | "\n", |
| 182 | + "## Coding Challenges\n", |
| 183 | + "\n", |
| 184 | + "| Challenge | Description |\n", |
| 185 | + "|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n", |
| 186 | + "| Change the key of each button | Use the frequency table in the comment section at the end of the code to change the notes that each button plays. |\n", |
| 187 | + "| Play more than three notes with if statements | By using combinations of buttons, you can play up to seven notes of the scale. You can do this in a few ways. To get more practice with if statements, try adding seven if statements and using the Boolean `and` operator to represent all of the combinations of keys. |\n", |
| 188 | + "| Play more than three notes with binary math | You can use a clever math equation to play more than three notes with your three keys. By multiplying each key by a different number, then adding up all of these numbers, you can make a math equation that produces a different number for each combination of keys. |\n", |
| 189 | + "\n", |
| 190 | + "## Troubleshooting \n", |
| 191 | + "| Problem | Solution |\n", |
| 192 | + "|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n", |
| 193 | + "| The buzzer is too loud or too quiet | Turn the potentiometer to adjust the volume. |\n", |
| 194 | + "| The RedBoard thinks one key is always pressed | Check your wiring. You may have ground and 5V backward if one or more buttons behave as though they're pressed all the time. |\n", |
| 195 | + "| The buttons are not working | First, make sure that the wiring is correct. It is easy to misalign a wire with a button leg. Second, make sure that you have declared your buttons as inputs and have enabled the internal pull-up resistors with `Pin.IN` and `Pin.PULL_UP` |\n", |
| 196 | + "\n", |
170 | 197 | "## You've Completed Circuit 2B!\n", |
171 | 198 | "\n", |
172 | 199 | "Continue to circuit 2C to learn about for loops, measuring durations, and put together all you've learned in project 2.\n", |
|
0 commit comments