It's a perfect time for a new project that highlights both my patriotism and nerdism simultaneously. While waiting for Core2 for AWS IoT EduKit to arrive from Reinventing Healthy Spaces with Amazon Web Services, I wanted to spend a little more time with nRF52840 Dongle that I got from Advanced Wearables with Nordic Semiconductor.
In this project we will build a device that plays the US National Anthem while it is connected to any Bluetooth device. The music will be played through a passive buzzer which is not loud enough; therefore, we had to use a transistor. Few people made similar projects already with Arduino IDE and CircuitPython so we don't have to start from scratch. We will however make it simpler (using simpleio library) and also use the on board RGB LED to show Red, White, and Blue colors in that exact order.
We will pick a pin (spoiler alert; P0.02) close to 5V and GND pins to be the base of the transistor. The other two legs will complete the buzzer circuit.
The code is pretty straight forward. The board will wait for any Bluetooth connection then it will play the US National Anthem while changing LED color with each note. The music will keep restarting while the board is connected.
The trickiest part of the code is getting RGB to display RW&B. Instead of using if statements, we just have to figure out when each color is on. Red will be on to display Red, and it will also be on to display White. Same for Blue. Green will be on only to display White since both Red and Blue will be on at the same time.
Comments
Please log in or sign up to comment.