**Installing RetroPie and Creating a Button**
The first step in creating a button to control the power state of your Raspberry Pi is to install GCC, which will be used to compile Python scripts for the project. "like 30 seconds and then one time I tried it and it took me 3 minutes to do it so just sit back and relax if it looks like it's frozen let it sit we're going to install GCC so we'll just go to number three pseudo AP get installed GCC press enter it was already installed and it's probably already installed for you if you're using retropi y 4.1 but I definitely suggest just trying it out make sure it is installed finally we need to get and install python pip Python pip enter wi for yes enter time to install python Raspberry Pi gpio package we'll just copy this and paste it over here press enter and it's fairly quick now"
Installing the necessary tools, including GCC and Python, is a crucial step in setting up RetroPie. The author recommends checking if GCC is already installed before attempting to compile any scripts, as this may save time.
Once the tools are installed, the author suggests proceeding with caution, ensuring that the script does not become corrupted during installation. "I've had really good luck over the lifespan of using the raspberry pi I used to just unplug it no problem and only one time out of the hundreds of times that I've ever unplugged it while it's running I had a corrupted SD card so it's booting back up now we're back up and running"
To ensure the integrity of the system, the author recommends testing the script by running it in a safe environment before proceeding with installation. This includes creating a new directory to hold the script and writing the necessary code.
**Creating the Script**
The script is created using a tool called Nano, which allows for line-by-line editing and modification of text files. The author begins by copying the contents of the "gpio" package into a new file, then uses Nano to make modifications as needed. "from here might look a little intimidating dating if you've never used it before we're going to copy everything from the hashtag all the way down to here copy and it's going to paste it right in there when you click the right button on your mouse now this is where I was talking about the save issue press contrl X if it doesn't work for you you're going to need to find another keyboard"
The author notes that using a tool like Nano can be intimidating, especially for those who are new to text editing. However, with practice and patience, anyone can learn to use it effectively.
**Configuring the Script to Run at Boot**
Once the script is complete, the author configures it to run automatically at boot time by adding a line of code that calls the script. "we want to copy python home scripts this is just going to call that script that we just wrote or we copied down to run at boot so we'll copy and over on this screen here you need to use your arrow keys to move down past the FI and we're going to paste that right in there now we're going to press contr X yes enter and and that's it"
The author explains that by adding a line of code, the script can be configured to run automatically every time the Raspberry Pi boots up. This is a crucial step in creating an interactive experience with RetroPie.
**Testing the Script**
To test the script, the author reboots the Raspberry Pi and presses the button attached to it. The script should now execute, powering on or off the Raspberry Pi as desired. "I've tested this over 50 times with the same SD card just to see if it corrupted anything I tried it over 50 times I sat here for about an hour turning it on and off just to make sure it doesn't corrupt the SD card"
The author emphasizes the importance of testing the script thoroughly, using multiple iterations to ensure that it functions as intended without causing any issues with the Raspberry Pi's storage.
"WEBVTTKind: captionsLanguage: enhey what's going on guys this ETA Prime back here again today I want to show you how to add a power button to your Asberry Pi while running retro Pi this will also work with raspian and pretty much any other Linux distribution that's based on Debian but this is really towards the people who want a dedicated off and on button on their arcade machines so first thing you're going to need is a switch I Rigg this one up here this is a very simple switch all it is is a momentary switch you press it and it Bridges the two wires and I'll leave a link down below to an Amazon page where you can get two squid buttons that are already set up with wires to plug right onto your GPO pins all right so let's go over the GPO pins that we need to connect to all we're going to be doing is bridging five and six so if you're looking at your Pi like this you're going to count three down 1 2 3 third row down five and six and I'm just going to plug my button directly on to five and six here now when we press the button it's just going to bridge those two GPI open pins read the script that we're going to set up shut the pie down and when you're ready to turn it back on you just press the button again so you can do this all from within retr Pi but I'm going to show you how to do it over SSH using a Windows machine this will work the same for mac and Linux you'll just need a different application or if you know how to run SSH from the terminal you can do it there we're going to be using putty on our PC first thing I want to do is go to retr Pi and grab our IP address we're going to move over there now all right so this is a fresh install of retro piy 4.1 and really the only reason we're going here now is just to grab our IP address you can scroll over to the Retro Pi logo enter it and go to show IP this is just in case you can't connect with just typing in retro Pi but your Raspberry Pi and your PC need to be on the same exact Network I have mine plugged in with ethernet and I also have my PC plugged in with ethernet to the same router if you're both on Wi-Fi they need to be connected to the same Wi-Fi network you can open up show IP right at the top of the gray box in the middle you will see your IP address take a picture of it write it down just remember it cuz you might need it we're going to be moving over to the PC now we're going to grab an application called putty this will allow us to SSH into the Raspberry Pi's file system next we're going to grab notepad++ and a text file that I created it's uploaded to a Dropbox account so you can just download it put on your desktop copy and paste these commands and this shouldn't take more than 10 minutes to get this done by yourself already have my button plugged in and if I press it now nothing's going to happen it's on GPI openin 5 and six let's move over to the PC now okay before we get started I just want to give a shout out to Barry hubard hubard Barry hubard that's what I'm going to call him he has a lot of great stuff and he's actually the one who created this script I did add a few things and the only thing I added was pseudo to the beginning of a few lines here because you need Rude access to to do some of these commands here it's very simple to do he actually if you want to go to this website and copy everything down from here you can it works perfectly you'll just need to add pseudo to some of the commands here next thing we're going to need is notepad++ and I recommend using notepad++ on your Windows machine for any kind of text editing it's amazing it labels everything for you numbers it for you and sometimes when you use the built-in Windows notepad on scripts it adds weird characters after you try to save it so definitely recommend getting notepad++ and the last application we are going to need is putty just download putty.exe you can place it on your desktop double click on it and it'll start the application no installation required down in the description you can download this text file it'll be uploaded to my Dropbox open it with notepad++ this is everything you need to get the button working and I have things numbered for us it should be easy for you to follow so go ahead and grab this because it's going to be easy to copy and paste and that's what I'm going to do in this video instead of having to type out these long commands here so I'm going to open up putty run my Raspberry Pi is still booted up connected to the same network as this PC and my host name needs to be all Capital retro Pi make sure SSH is checked if you try to connect with retro pi and it doesn't work for you type in your IP address of your Raspberry Pi click open yes and I'm just going to snap this over to the right side here we're going to log in as Pi Pi and our password is raspberry press enter we now have access to a rasp Berry PI from our PC let's open up that text file in notepad++ snap it to the side here so my Raspberry Pi is still on and connected to the same network needs to be in order for you to access this we're going to go ahead and install python copy paste enter now one thing that I've noticed I have a Dell keyboard that I cannot save within this SSH if I press control X so if you're not able to save at one of these parts you may need to get a different keyboard set up I don't know what it is but my Dell keyboard just will not save and to save you need to press contrl X it's weird press y for yes and enter next when it's done you'll see the pi at retro Pi we're just going to go to number two and install Python 3 copy copy paste enter y for yes enter this really depends on the speed of your internet the speed of your SD card and how fast they're serving or how many people are taking information from these sites at the given time I've had it take like 30 seconds and then one time I tried it and it took me 3 minutes to do it so just sit back and relax if it looks like it's frozen let it sit we're going to install GCC so we'll just go to number three pseudo AP get installed GCC press enter it was already installed and it's probably already installed for you if you're using retrop piy 4.1 but I definitely suggest just trying it out make sure it is installed finally we need to get and install python pip Python pip enter wi for yes enter time to install python Raspberry Pi gpio package we'll just copy this and paste it over here press enter and it's fairly quick now we need to uncompress or extract that package we just downloaded copy paste enter done now we need to move into our newly created directory and we're going to CD so CD rp. gpio enter we are now in the newly created directory we're going to install the module we're going to create a new directory to hold our scripts copy paste mkdir that will make a directory and it's going to be in home pi and the folder is going to be called scripts or the directory press enter we now have a new directory now we need to add the script and we can do that by using Nano we're going to create a script in that newly created directory press enter from here might look a little intimidating dating if you've never used it before we're going to copy everything from the hashtag all the way down to here copy and it's going to paste it right in there when you click the right button on your mouse now this is where I was talking about the save issue press contrl X if it doesn't work for you you're going to need to find another keyboard I haven't found a way around it with my Dell keyboard so contr X save modified buffer at the very bottom as you can see press y enter we can test the script if we'd like to but right now I'm not going to test it cuz I know it's going to work it's kind of like buying a card in eggs from the store and you don't open it up to see if there's any cracked ones let's go ahead and do this we're going to configure the script to run at startup copy now it's going to bring us into another Nano window we want to copy python home scripts this is just going to call that script that we just wrote or we copied down to run at boot so we'll copy and over on this screen here you need to use your arrow keys to move down past the FI and we're going to paste that right in there now we're going to press contr X yes enter and and that's it it's time to move to the Raspberry Pi now you can reboot if you'd like by going pseudo reboot and I do recommend rebooting one time that's going to reboot the P we're going to get disconnected here on the PC as you see so I'm going to be moving over to the pi and show you that our button is now working so I have the pi connected and I have my pin on gpio 5 and 6 just a little momentary switch I know the camera is a little weird because of the background of the TV but you'll still be able to see me push this button and restart the pie just going to shut it down give it a few seconds after that green light stops flashing on your pie you can press it again to boot it up so what I did was I tested this over 50 times with the same SD card just to see if it corrupted anything I tried it over 50 times I sat here for about an hour turning it on and off just to make sure it doesn't corrupt the SD card now I've had really good luck over the lifespan of using the raspberry pi I used to just unplug it no problem and only one time out of the hundreds of times that I've ever unplugged it while it's running I had a corrupted SD card so it's booting back up now we're back up and running we can press the button to shut it down now the pie is completely shut down I'll press it again to turn it back on and this is the last time guys guys I really appreciate you guys watching if you could hit that like button and subscribe and yeah I mean this works out great you could throw this in your arcade cab on the back you can use any kind of momentary switch that you'd like to use I prefer using the momentary switches instead of an onoff switch and those are the only tutorials I've made so far have another one on recall box it's much easier to set up but this works just as well with retro pi and a lot of people have asked me about it so I figured I'd get around to doing it like always thanks for watchinghey what's going on guys this ETA Prime back here again today I want to show you how to add a power button to your Asberry Pi while running retro Pi this will also work with raspian and pretty much any other Linux distribution that's based on Debian but this is really towards the people who want a dedicated off and on button on their arcade machines so first thing you're going to need is a switch I Rigg this one up here this is a very simple switch all it is is a momentary switch you press it and it Bridges the two wires and I'll leave a link down below to an Amazon page where you can get two squid buttons that are already set up with wires to plug right onto your GPO pins all right so let's go over the GPO pins that we need to connect to all we're going to be doing is bridging five and six so if you're looking at your Pi like this you're going to count three down 1 2 3 third row down five and six and I'm just going to plug my button directly on to five and six here now when we press the button it's just going to bridge those two GPI open pins read the script that we're going to set up shut the pie down and when you're ready to turn it back on you just press the button again so you can do this all from within retr Pi but I'm going to show you how to do it over SSH using a Windows machine this will work the same for mac and Linux you'll just need a different application or if you know how to run SSH from the terminal you can do it there we're going to be using putty on our PC first thing I want to do is go to retr Pi and grab our IP address we're going to move over there now all right so this is a fresh install of retro piy 4.1 and really the only reason we're going here now is just to grab our IP address you can scroll over to the Retro Pi logo enter it and go to show IP this is just in case you can't connect with just typing in retro Pi but your Raspberry Pi and your PC need to be on the same exact Network I have mine plugged in with ethernet and I also have my PC plugged in with ethernet to the same router if you're both on Wi-Fi they need to be connected to the same Wi-Fi network you can open up show IP right at the top of the gray box in the middle you will see your IP address take a picture of it write it down just remember it cuz you might need it we're going to be moving over to the PC now we're going to grab an application called putty this will allow us to SSH into the Raspberry Pi's file system next we're going to grab notepad++ and a text file that I created it's uploaded to a Dropbox account so you can just download it put on your desktop copy and paste these commands and this shouldn't take more than 10 minutes to get this done by yourself already have my button plugged in and if I press it now nothing's going to happen it's on GPI openin 5 and six let's move over to the PC now okay before we get started I just want to give a shout out to Barry hubard hubard Barry hubard that's what I'm going to call him he has a lot of great stuff and he's actually the one who created this script I did add a few things and the only thing I added was pseudo to the beginning of a few lines here because you need Rude access to to do some of these commands here it's very simple to do he actually if you want to go to this website and copy everything down from here you can it works perfectly you'll just need to add pseudo to some of the commands here next thing we're going to need is notepad++ and I recommend using notepad++ on your Windows machine for any kind of text editing it's amazing it labels everything for you numbers it for you and sometimes when you use the built-in Windows notepad on scripts it adds weird characters after you try to save it so definitely recommend getting notepad++ and the last application we are going to need is putty just download putty.exe you can place it on your desktop double click on it and it'll start the application no installation required down in the description you can download this text file it'll be uploaded to my Dropbox open it with notepad++ this is everything you need to get the button working and I have things numbered for us it should be easy for you to follow so go ahead and grab this because it's going to be easy to copy and paste and that's what I'm going to do in this video instead of having to type out these long commands here so I'm going to open up putty run my Raspberry Pi is still booted up connected to the same network as this PC and my host name needs to be all Capital retro Pi make sure SSH is checked if you try to connect with retro pi and it doesn't work for you type in your IP address of your Raspberry Pi click open yes and I'm just going to snap this over to the right side here we're going to log in as Pi Pi and our password is raspberry press enter we now have access to a rasp Berry PI from our PC let's open up that text file in notepad++ snap it to the side here so my Raspberry Pi is still on and connected to the same network needs to be in order for you to access this we're going to go ahead and install python copy paste enter now one thing that I've noticed I have a Dell keyboard that I cannot save within this SSH if I press control X so if you're not able to save at one of these parts you may need to get a different keyboard set up I don't know what it is but my Dell keyboard just will not save and to save you need to press contrl X it's weird press y for yes and enter next when it's done you'll see the pi at retro Pi we're just going to go to number two and install Python 3 copy copy paste enter y for yes enter this really depends on the speed of your internet the speed of your SD card and how fast they're serving or how many people are taking information from these sites at the given time I've had it take like 30 seconds and then one time I tried it and it took me 3 minutes to do it so just sit back and relax if it looks like it's frozen let it sit we're going to install GCC so we'll just go to number three pseudo AP get installed GCC press enter it was already installed and it's probably already installed for you if you're using retrop piy 4.1 but I definitely suggest just trying it out make sure it is installed finally we need to get and install python pip Python pip enter wi for yes enter time to install python Raspberry Pi gpio package we'll just copy this and paste it over here press enter and it's fairly quick now we need to uncompress or extract that package we just downloaded copy paste enter done now we need to move into our newly created directory and we're going to CD so CD rp. gpio enter we are now in the newly created directory we're going to install the module we're going to create a new directory to hold our scripts copy paste mkdir that will make a directory and it's going to be in home pi and the folder is going to be called scripts or the directory press enter we now have a new directory now we need to add the script and we can do that by using Nano we're going to create a script in that newly created directory press enter from here might look a little intimidating dating if you've never used it before we're going to copy everything from the hashtag all the way down to here copy and it's going to paste it right in there when you click the right button on your mouse now this is where I was talking about the save issue press contrl X if it doesn't work for you you're going to need to find another keyboard I haven't found a way around it with my Dell keyboard so contr X save modified buffer at the very bottom as you can see press y enter we can test the script if we'd like to but right now I'm not going to test it cuz I know it's going to work it's kind of like buying a card in eggs from the store and you don't open it up to see if there's any cracked ones let's go ahead and do this we're going to configure the script to run at startup copy now it's going to bring us into another Nano window we want to copy python home scripts this is just going to call that script that we just wrote or we copied down to run at boot so we'll copy and over on this screen here you need to use your arrow keys to move down past the FI and we're going to paste that right in there now we're going to press contr X yes enter and and that's it it's time to move to the Raspberry Pi now you can reboot if you'd like by going pseudo reboot and I do recommend rebooting one time that's going to reboot the P we're going to get disconnected here on the PC as you see so I'm going to be moving over to the pi and show you that our button is now working so I have the pi connected and I have my pin on gpio 5 and 6 just a little momentary switch I know the camera is a little weird because of the background of the TV but you'll still be able to see me push this button and restart the pie just going to shut it down give it a few seconds after that green light stops flashing on your pie you can press it again to boot it up so what I did was I tested this over 50 times with the same SD card just to see if it corrupted anything I tried it over 50 times I sat here for about an hour turning it on and off just to make sure it doesn't corrupt the SD card now I've had really good luck over the lifespan of using the raspberry pi I used to just unplug it no problem and only one time out of the hundreds of times that I've ever unplugged it while it's running I had a corrupted SD card so it's booting back up now we're back up and running we can press the button to shut it down now the pie is completely shut down I'll press it again to turn it back on and this is the last time guys guys I really appreciate you guys watching if you could hit that like button and subscribe and yeah I mean this works out great you could throw this in your arcade cab on the back you can use any kind of momentary switch that you'd like to use I prefer using the momentary switches instead of an onoff switch and those are the only tutorials I've made so far have another one on recall box it's much easier to set up but this works just as well with retro pi and a lot of people have asked me about it so I figured I'd get around to doing it like always thanks for watching\n"