I “hacked” a Raspberry pi

Sort of…

--

Generated by Midjourney Bot

When you think of a Raspberry Pie, you probably think about the enticing smell and the joy you get when devouring a piece of one. But, when I think about a Raspberry Pi, I think about, programming, circuitry, and microcomputers. I think we are thinking of 2 different things…

A Raspberry Pi is a microcomputer which can be used for many different things.

Side note: I will probably call a Raspberry Pi a Pi or an RPI, just for simplicity.

RPI’s have something called General Purpose Input/Output (GPIO) pins. These pins allow you to connect to a breadboard and build circuits. Different pins have different functions. For example, there are multiple 5v, 3.3v, GND, and other pins which allow for programs to be connected to circuits.

I’m planning on releasing a few more blogs about RPI, like a beginners guide to raspberry pi, and some fun projects to try if you have 2 of them lying around. Let me know down below for some other RPI ideas.

We’ll get to the hacking in just a minute, but first I’m going to showcase 3 projects which I built (one of which is “hacking”), just using some basic circuitry and code. All my code is in GitHub, I will share links to that later. Also, the original code is from Freenove, but I have made my edits on the code to make cooler projects. Alright, first up, Liquid Crystal Display!

Displaying time and temperature with an LCD Module

This project utilizes 2 main components, an LCD Module and a temperature sensor. I’m not going to go into the details of how an LCD works, but it’s pretty cool. Basically, it uses liquid crystals to polarize light and only project what it wants to on the outside.

The following 2 circuits are on the breadboard at the same time for this to work:

Image by Freenove
Image by Freenove

You can access my code (in GitHub) linked here.

Controlling a game with an external joystick!

There are in fact joysticks which can be connected to a circuit board and controlled the way you want. The one I use for this project came with my Freenove kit. This project also requires an ADC, which is a device that can convert analog to digital signals.

Here is the circuit:

Image by Freenove

The joystick returns 3 values to the computer: the x axis values (side to side), the y axis values (up to down), and the z axis values (whether or not the button is pressed). Using some basic conditionals, we can make the computer do whatever we want when the joystick is moved. The joystick values range from 0 to 256 (for the x and y axis) and between 0 and 1 for the z axis.

The green device in the center is the ADC module. You must be asking, why do we need to convert between Analog and Digital signals? In fact, what the heck are analog and digital signals??!

This might give some of you a throwback to my blog on mechanical computers. If you haven’t read that yet, check it out here!

Alright, back to business! A digital signal is a signal that only returns 2 possible values. For example, when you push a button, either the button is pressed, or it’s not, there is no in between.

Meme made by author

An analog signal, on the other hand, returns a range of values. It can be anywhere from -10000 to 10000. It depends on the device which you’re dealing with. Most computers these days are digital.

Why do we need an ADC in this project? Well, as mentioned before, the x an y axes of the joystick returns a range of values, meaning this needs to be converted to a digital signal for it to be read by the GPIO. Since the z axis is just the push of a button, it is already a digital signal.

Check out the code here!

‘Hacking’ my volume control so I can control it with a potentiometer:

We’ve come to the part of the blog where I tell you… I lied. I didn’t really ‘hack’ per say, but I just used some useful libraries to be able to control my volume (hence the quotation marks whenever you see the word ‘hack’). To understand the following circuit, you have to understand how a potentiometer works.

A potentiometer is basically a resistor that can be adjusted. It’s resistance can be changed by rotating the knob. Based on it’s resistance, it returns a value back to the computer. Since the output is analog, we need an ADC again to convert it to a digital signal. In fact, a joystick is just 2 rotary potentiometers placed perpendicularly to each other to detect rotational motion along 2 axes.

Using some basic conditionals, I could increase/decrease the computer volume whenever the potentiometer value is changed. I actually used a library which simulates pressing a key on your keyboard. Depending on the potentiometer value, I can simulate pressing the volume button key that many times.

You can check out my code here.

I hope you enjoyed these fun projects and learned something new! Stay tuned for more cool technology.

--

--

Ankit Durbha
Computer Science: A teenager’s perspective

I created the publication Computer Science: A teenager's perspective with the goal of creating a community of like-minded, technology enthusiastic peers.