**DIY Radio Project: A Step-by-Step Guide**
In this project, I will be sharing my experience of building a DIY radio using an Arduino Uno, a rotary encoder, and other components.
I used the MCP 4151 8-bit, 10 kΩ digital potentiometer, which uses the SPI communication interface to set its wiper position. This means that it needs to connect to the predetermined SPI pins of the Arduino in order to work correctly, and we can easily use the SPI library to send out values between zero and 255.
I used a simple for loop to slowly increase the send value, which therefore increases the resistance between one side of the potentiometer and the wiper. By connecting the audio outputs of the FM radio to one side of the potentiometer, ground to the other side, and the wiper to the input of the audio amp, it acts like a voltage divider, which can decrease the peak-to-peak voltage of the audio signal and thus the volume.
Next, I wanted to choose those scent values easily, so I went with a rotary encoder. By connecting 5V power to it and hooking its data and clock line up to my oscilloscope, we can see that by turning the shaft clockwise, the data line falls down to ground for a short period of time before the clock line does. Opposed to this, if I turn the shaft counterclockwise, the clock line gets pulled to ground before the data line.
This behavior can be used in our favor by using the interrupt pins two and three of the Arduino. An interrupt basically monitors the state of the input pin constantly, and once it changes by falling or rising, it executes a function which, in my case, finds out whether we turn the up clockwise or counterclockwise.
This way, we can increase or decrease the volume value, which is shown here through the serial monitor. But as you might have already noticed, sometimes the value jumps up or down many times through one simple turn, which is not right. This occurrence is called bouncing and can easily be fixed the hardware Way by adding a capacitor between the pin and ground.
Lastly, we need an LC display in order to see what the current FM and volume settings are. I hooked it up the usual way but needed to use other pins than the recommended ones from the LiquidDisplay Library. Nevertheless, it worked like a charm after fine-tuning the contrast with a potentiometer at the end of this prototype assembly.
**Prototype Assembly Completion**
After completing the codes by implementing maximum and minimum values, the radio is complete if you want to use it on a breadboard. But since I don't want to do that, I got myself a lithium-ion cell hooked it up to a TP 4056 charging and protection circuit and connected its output to an MT3608 voltage booster.
Make sure to adjust its output voltage to around 5 volts through its potentiometer before powering the breadboard circuit with it. Now that everything works just as planned, I freed my breadboard from the wire and component chaos sorted all the parts for the build and completed my schematic to make the circuit permanent.
**Perf Board Assembly Completion**
I used the perf board with copper dots which I snapped to a size of around 8.2 X 7.6 CM then I attached male headers to my Uno Pro Mini and also soldered 10-pin and five-pin female headers onto the board. These will later be used for the LCD and rotary encoder, which both got wires fixed to the pins while the other side of the wires received M headers with shrinking tube to avoid shorts.
Afterwards, I sorted in the TA 5767 the remaining IC sockets and the Boost converter, and at this point, it was basically an act of connecting all the pins to each other according to the schematic through silvered copper wire or later on through thin flexible wire. Of course, you can find the schematic codes a parts list and better pictures in the video description to easily rebuild this project.
**Uploading Code**
After 4 hours of soldering the perfboard assembly was finally complete, and by hooking it up to 4V power I was capable of uploading the code to the Arduino through FTDI breakout, and surprisingly everything still worked even on the first try.
And with that being said, we also need to build an awesome case in the next part. Check back for Part Two in one week until then don't forget to like share and subscribe that would be awesome stay creative and I will see you next time.