Creating a (terrible) video game console

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone I have a bunch of electronics from a little beginners kit that's just been sitting on my shelf for ages but I felt like taking a break from my usual routine today so I'm dusting the stuff off and trying to build a video game console the brains of this operation is going to be this little device which for those unfamiliar is an Arduino Uno and it's got a teensy little computer on it here which we can write programs for along the sides are a number of pins where we can connect stuff and roughly speaking the program can supply a voltage to any of those pins alternatively read the voltage coming in to them now I have this little joystick which will be perfect as a means of input but I'd like to know a bit about how it works before I use it the internet tells me it's got two potentiometers inside and I know this can be used to do things I could just the volume of a speaker or the brightness of a light but I'm not sure how that relates to the joystick so I've done a little research and learnt that when I twist the knob a little piece of metal inside called the wiper turns along a resistive track if this is connected to a battery like so then the further the electricity has to struggle along a track to get to the wiper the less current is going to be here that explains the light getting dimmer but another way we can use it is to attach the battery across the answer terminals and then measure the voltage between the wiper and an outer terminal will read zero when the wiper is all the way on this end going up to the full voltage on the other end so that's kind of cool because knowing this voltage effectively tells us how much the knob has been turned so if the joystick turns one potentiometer with x axis movement and the other with y-axis movement then reading those two voltages will tell us where the joystick is to make sure I is understanding this right I connected the potentiometer up to the Arduino and I then plugged one end of a USB cable into my slightly odd-looking computer and the other end into the Arduino to power it up I then wrote a little script which just reads the voltage at pin zero which is where connected the potentiometer and then prints that value out so if I now press the upload button that'll send the script along the USB cable to the Arduino which will run it and constantly send the results back to the computer to be printed out so as you can see the value is zero at the moment but as I turn the knob that number increases before you fall off your chair this doesn't mean there's over a thousand volts that'd be mildly dangerous the max is actually 5 volts but that gets converted to a 10 bit integer giving us a range of 0 to 1023 all right so I'll finally replace the potentiometer with the joystick and I'll just need one extra wire for the y-axis potentiometer I'll also quickly modify the code to read in the y-value and transform the inputs to be in the range negative 1 to positive 1 because that just makes a little more sense for a joystick finally I'll ask it to print out the result and upload the code I'll play around with the joystick a little but as far as I can tell it's working nicely so the next thing I need for my console is some sort of screen to actually display stuff on I got the simplest and cheapest thing I could find which was this 8 by 8 matrix of red LEDs I'll quickly plug those in and then using a library I found I can very easily set the individual LEDs on the display like so now you might be thinking 64 pixels is not a whole lot of pixels which is why I actually splashed out on a second display to give players the extravagant widescreen experience they deserve [Laughter] of course sound also plays a vital role in amassing a player in the game world and so luckily I have this little device capable of a wide range of annoying buzzing noises this is controlled by rapidly alternating between setting the voltage to high and low causing the plate in the buzzer to vibrate there is also a handy function called tone where one can just set a frequency and duration and it handles all that stuff for you I wanted an easy way of writing music for the buzzer so I decided to create a little editor I made this in the unity engine and there you have this function called an audio filter Reed where you can directly set the audio data so using a simple sine wave I can make it play sounds at different frequencies alright so let's see on my masterpiece that was a little underwhelming but the point is that I can then export the result as a raise of Note frequencies times and durations which can be used to play the song back on the buzzer that sound really is annoying though so I ended up scrapping the whole music idea I guess I can still use the buzzer for little sound effects instead so with input display and audio all sorted out I put together a little prototype version of the console next I wanted to make a game and since I'm just bursting with creativity I have decided to make snake now the Arduino can be programmed in C or C++ neither of which I've ever used but the syntax is very similar to c-sharp so with my knowledge of that and maybe one or two visits to Stack Overflow I was able to get it working I'll quickly show a bit of my terrible code for anyone who might care so I have this engine class which is mainly responsible for getting player input and setting pixels in this function I was originally turning the LEDs on individually but that turned out to be surprisingly slow eating up like 15 milliseconds per frame I'm trying to build the next gen console here so that obviously wasn't going to fly what I did instead was create two arrays for the rows in display a and B and the function now just sets the bits in those once the games update stuff is complete then that data gets sent row by row to the LED controller which is the library I mentioned earlier that handles communication with the displays I then also have a console script which essentially gives the engine to the current games that it can use it this was probably the most confusing part of the programming for me with all these weird symbols forgetting memory addresses and so on but once I'd vaguely wrap my head around that I created another simple game where you have to shoot incoming spaceships oh whatever you like friendly the graphics admittedly leave some room for interpretation with too little games complete I was ready to move on to constructing the console I first made some models of the different components in blender and started trying to figure out how to arrange them I wasn't sure where to put the Arduino because I didn't want a big empty space but it's also awkward to put something on top of it I thought about turning it upside down and having the joystick on top but with why is connecting off the bottom here it seemed a little awkward I eventually settled on this three-tier design so I got some balsa wood because it's nice and easy to cut and sanded the rough edges on a nail file stuck down to my desk as you can see this is a very professional operation I then made some holes in the middle layer for the wires to run through but the wires I had were all awkwardly long so I spent some time cutting stripping and taping off a bunch of them one side verified that my little wires were actually working I began gluing stuff down when the sticky process was complete and everything was in its place I ran the wires through the holes I'd made earlier and finally connected them up to the Arduino via a breadboard for anyone wondering a breadboard is basically a slab of plastic with little holes in it on the inside the holes are connected together with metal clips making it really easy to join components together without the fuss of melting metal okay so with the wiring complete I noticed needed to make it pretty this part didn't go so well I started by cracking the wood and then somehow managed to glue the cover on the wrong way around not just once but twice I managed to get it together in the end though and I brushed on a few layers of acrylic sealant and painted it an attractive shade of yellow I thought it looked rather handsome but I was told it looked like a terrifying monster so I added a pair of ferocious eyebrows and experimented with a silly tongue and some scary teeth at last it was time to switch it on I was really excited when the finished thing actually worked I can now shoot dots and place make to my heart's content the only annoying thing is being tethered to the computer but once the program is loaded on it just needs power so I'll grab my 9 volt battery on this little adapter thingy and plug it in hello ok I'm back with some Dutch Lee tape together double A batteries and that seems to work alright I am off to begin my new life of leisure so that brings me to the end of this project I know the end result is not terribly impressive I've pretty much just wired together some pre-built components and shoved them inside a poorly constructed box but nonetheless I'm strangely proud of this little monstrosity I've created I certainly had a lot of fun making it and learning some basic electronics along the way and I think will be fun to attempt a more elaborate project sometime in the future anyway thanks for watching and until next time managers
Info
Channel: Sebastian Lague
Views: 2,170,142
Rating: undefined out of 5
Keywords: electronics, arduino, arduino uno, programming, coding, video game, video game console
Id: TURzbXTNaA0
Channel Id: undefined
Length: 9min 21sec (561 seconds)
Published: Wed Nov 27 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.