Can a Raspberry Pi be used as an Arduino? || RPi GPIO Programming Guide 101

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
recently I noticed that our own quite a few sing about computers which includes three raspberry pies the only problem is that I rarely use them for electronics projects which means they just sit around collecting dust so in order to change that let's go on an educational journey in which we will find out how easy it is to control the GPIO s of Raspberry Pi and whether it can truly replace an Arduino development board let's get started [Music] this video is sponsored by JL CPCB one fact about them PCBs from jlc PCB are entirely tested via 405 protesters and 10 AIO AI machines upload your Gerber files to order ten professional PCBs for only two dollars first off we have to decide which incarnation of Raspberry Pi we will use I went with the Raspberry Pi three year model B since it is the newest version that I own next we need a micro SD card I inserted it into a computer downloaded the newest version of raspbian unzipped it and installed it onto the micro SD cards with the win32diskimager software afterwards I inserted the micro SD card into the PI connected a keyboard and mouse through USB as well as a screen foon HDMI cable and powered up the system with a five-fold phone charger at this point the Raspberry Pi will configure the operating system and after staring at a black screen for two minutes I was greeted with the usual desktop now he began the confusing part for me since I had no idea what programming language to use and how to execute the written codes but let's start basic for programming the two most common languages for the Raspberry Pi - and see and since the Arduino programming language is more or less simplified see you let's stick to the C language for first pieces of codes to start with I opened the terminal and typed in man GPIO which opened the manual for the GPIO tool of the wiring PI library which means it was already installed wiring pi is a pin based GPIO access library written C which is mandatory for our codes so feel free to visit its website for more information about it or how to install it if it is not pre-installed on your version of raspbian anyway now we could create a new file give it a dot C file name open it with the text editor and basically start coding but it wouldn't quite be right if we compare it to the arduino with its nicely color-coded ide software so let's rather go ahead and instead utilize the preinstalled genie ID here to write our codes after creating a new dot c file we must firstly include the wiring PI library and after declaring the pin number and creating the main void function we have to initialize the library a' by using one of those three commands the difference between them is the pin numbering of the GPIO s if we once again use the terminal we can execute the previously discovered with all commands from the manual and thus see the different pin numbering scheme of the three systems I went with the Broadcom GPIO pin numbering for my codes and continued by utilizing the pin mode function digits write function and delay function to create a simple blink codes disregarding the effects that there is now set up a loop section but only a main void section that we must manually loop over Neverending while construct such code syntax should be familiar to anyone who used Arduino before or anyone who watched mouth we know 101 102 and 103 video series to use the code though we must firstly open this Pokemon's and at the wiring pie library to the compile and build segment and at the sudo command to the execute section next we can click the build icon and once that process was completes we can click the execute icon which brings up a new terminal window that means it was time to connect the ground and the utilize GPIO pin to an LED with current limiting resistor on a breadboard and as you can see the blink codes work without a problem in this case the only difference to nod reno circuits is that the Raspberry Pi uses 3.3 volts voltage levels instead of the 5 volts voltage levels of an Arduino next let's add an inputs to our codes which once pressed turns on the previously utilized GPIO pin and as you can see the Raspberry Pi not only offers pull-up resistors just like the Arduino but also offers pulldown resistors which is a useful feature to have anyway after building / executing the codes and adding a push-button to the circuits and wiring it up we can once again confirm that the code works fine as the last example let's add one of the four available PWM pins as a PWM outputs and create a PWM signal mover 50% duty cycle after executing the codes and hooking up the assigned GPIO pin to the oscilloscope we can observe the correct PWM signal which even offers a high frequency of 300 kilohertz to adjust the duty cycle let's add a potentiometer as an analog inputs to the circuits which brings me to the two problems of the raspberry pi considering the programming they are now include the timers and no ADC which means know precisely timed events and no measuring of analog voltages now don't get me wrong since the Raspberry Pi supports you arts I squared C and SPI we can easily add an external ADC and since many of the Arduino commands and even a couple new helpful ones are included the Raspberry Pi can almost be considered an Arduino substitute but Arduino projects which only require a minimum of data processing are not the main field of application for Raspberry Pi which brings me to Python as you can see here it is also a programming language there is supposedly very beginner friendly but of course for someone like me who used C all his life I will need some time to get used to it it can basically execute all functions let the C language offers but it also comes with so-called Python packages by searching for raspberry pi with the Python package index we can find a few dozens of Awesome modules that we could easily implement in our own codes including a 2d plotting package or a package that can do FFT signal and image processing what I'm trying to say is that the Arduino is the way to go for more straightforward electronics projects but when it comes to more data excessive projects like a smart mural or the mapping of an unknown environments the Raspberry Pi is the way to go I hope you enjoyed watching this video and learned a thing or two about the C and Python language also let me know what Raspberry Pi projects you would like to see in the future on this channel as always don't forget to Like share and subscribe stay creative and I will see you next time
Info
Channel: GreatScott!
Views: 485,888
Rating: undefined out of 5
Keywords: raspberry, pi, rpi, arduino, tutorial, diy, how to, how, to, make, project, gpio, GPIO, control, program, programming, geany, guide, beginner, beginners, C language, python, language, wiringpi, wiringPi, broadcom, physical, number, numbering, ide, IDE, smart, mirror, magic, packages, package, index, instal, led, blink, input, output, adc, timer, greatscott, greatscott!, electronics
Id: tQEmtbaO2GY
Channel Id: undefined
Length: 8min 14sec (494 seconds)
Published: Sun May 06 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.