Section five physical computing with raspberry pi four. In this section, we will cover the following topics. Getting started with physical computing on the Raspberry Pi four introduction to hardware interfacing on the Raspberry Pi for working with LEDs and buttons, working with LDR and PIR sensors, working with relays, working with ultrasonic sensor and DC motors. Working with you art I two C and SPI protocols. Video getting started with physical computing on the Raspberry Pi four. In this video we will learn about physical computing its working principle and finally, get a deep understanding of the GPIO pins.
Physical computing is the place where computer science meets electronics. In layman's terms, physical computing refers to the creation of devices that interact with the world around them. Such a device would be able to sense its environment, process the data and perform some action. Thus, sense think act cycle is the core principle of physical computing. physical computing opened up space for learners to explore computational ideas in a creative and interactive way. This approach of interdisciplinary learning offered by physical computing is one of the key factors for innovations in fields like Internet of Things and smartphones.
You may have seen some really cool Raspberry Pi hardware projects, but we'll take a closer look. They seem impossibly complex. It's all rather dark. But we are not. It's simpler than it looks. The functions of any physical computing project can be split in three ways.
The computer measures inputs, it uses software to think about what it will do with those measurements, then it makes something happened with a result. If you see a project you'd like to make, then splitting it into those three parts makes it much simpler to understand. Taking a look at those inputs, just how does a computer measure something? The answer is that it asks a sensor connected to one of its inputs and receives the reading. That sensor can be as simple as a push button, a temperature sensor, or a PI camera module. It doesn't even need to be physical hardware.
For instance, a feed of the temperature in your city from the internet or the current time from the PI's clock could both be inputs. The information there Turn can then refer to the software for the thinking stage. Finally, with the inputs rate and the decisions made by the software, the computer must do something for that it needs outputs, things that transfer from the software to the real world. These can be as simple as an LED a server in a robot, or even a mechanism of a 3d printer. Again, they don't even need to be physical. For example, a piece of software can send a tweet as its output.
What type of project you create is up to you be just a fun or to solve a practical problem does the sense thing act cycles becomes the core working principle of physical computation. Until now, this course has focused on the Raspberry Pi software side. But now we'll get into the hardware. Take your Raspberry Pi four and on the top edge You can see a row of pins. This is the most powerful feature of the Raspberry Pi fold. These pins are called general purpose input output pins, or GPIO.
In short, the Raspberry Pi four is just like a brain in a job. We have to Frankenstein our way to make it alive. The GPIO pins are a physical gateway between the pifo and the outside world. Understanding the functions of these pins are crucial for anyone working with a Raspberry Pi four. If you count, you can see that there are 40 pins on the Raspberry Pi for split equally across two rows. Please download the following pinout diagram given in the resources and take a color printout before we learn the functions of each pin while programming on the PI four.
If you need access to the pinout diagram right on the terminal. You can just to pin out on the terminal and you will see the pin out. The PI's 48 GPIO expansion header has many more possibilities than it has pins. Basically, there are two types of pins on the PI. They are GPIO pins and power pins. The power pins include two fibers pens, to 3.3 volts pens and eight ground pins.
The five volts pens give direct access to the five volt supply coming from your power supply. It can be used to power other five volt devices when using these pins directly. Be careful and check your voltages before making a connection because they bypass any safety measures, such as the voltage regulator and fuse, which are there to protect your PI. bypass these with a higher voltage and you could render your pipe inoperable. Similarly Many peripherals work on 3.3 volts power and thus the PI provides that too. Now, if you subtract the power pins from the total pens, you will get the number of GPIO pins which is 28 in number.
These GPIO s are on off pens that you can either use as outputs or inputs, sending or receiving logic one or logic zero voltage levels. Use one anywhere if simple on or off condition is required. For example, to turn on or off an LED or to sense whether a button has been pressed. Sometimes you need more than just switching on and off depends. Most of the GPIO pins comes with secondary functions that allow them to interface with different kinds of devices like I to see SPI or UART protocols. We will discuss these various protocols in detail with that Hardware interfacing to make you understand the concept much more.
For now, just keep in mind the following things before we explain the pinout. To implement ITC protocol, you will need two GPIO pins. To implement UART protocol, you will need two GPIO pins. To implement SPI protocol, you will need a minimum of four GPIO pins. Now keeping that in mind, if you take a look at this functional pinout diagram, it's clear that we have six ITC bus implementations, five UART bus implementations and six SPI bus implementations on the PI four, I have provided a detailed spreadsheet in the resources as shown here, which will give you a much clearer idea of what all features each GPIO pin is capable of doing. You might use these buses to interface an asset LCD display, a temperature sensor, analog to digital converter and many more sensors and activators.
The way they packed in many functionalities to eight GPIO pins is by using the concept of multiplexing. It allows switching between functions supported by a GPIO at a time a GPIO can be configured to attach to different pins of the main processor, so that a specific function can be enabled. The only disadvantage of multiplexed GPIO is that at a time, only one function can be used. Please remember that all of those active GPIO pins lead directly into the CPU on your PI four. And thus, if you apply too much voltage or current to them, you can damage it. They normally work at 3.3 volts and 10 milli amperes.
So precautions such as using a resistor with an LED should be taken To use your PI with a five volts device, such as an Arduino, special add ons are available to protect your PI and give you a buffer set of GPIO s to safely work with summary. In this video we have covered the following what is physical compute ation? What is the working principle of physical computation, a detailed overview of the GPIO pins. In the next video, we will start working on simple hardware interfacing using Python