In this tutorial, we will interface the push button with our VIsionFive board. Led will be remained on until for next time the button is pressed. It will not be turned o otherwise. It is similar to the Arduino's button debounce sketch. But as it is in python and on VisionFive, it will be a little dierent and easier and with fewer lines of code. It can include the following things:
- INPUT -|- Getting Values or state change detection at VisionFive’s GPIOs
- OUTPUT -|- Setting State at VisionFive’s GPIOs
- What is the button?
- Default State of VisionFive’s GPIOs
Push-button is the same as any button whose function is to close or open the circuit when pressed. It is the simplest Input device. It’s in almost every electronic appliance which includes users' inputs. It usually consists of 4 terminals or even 2 and 3. But technically all we have to use only 2 terminals. We can easily interface it with VisionFive, Arduino, Raspberry Pi, Beaglebone, or any other microcontroller.
“VisionFive, the iteration version of StarLight single-board computer, has the same performance and con;gurations as the previous version. It is the world’s ;rst generation of aordable RISC-V boards designed to run Linux. Based on the RISC-V architecture, VisionFive pushes open-source to the next level and gives developers more freedom and power to innovate and design industry-leading solutions.”
It has 40 GPIOs, making it easier to control and interface with the environment and the world.
Circuit Diagram is really simple and straightforward. The following image is available on RVspace. It was followed for connections.
For More Information about GPIOs you can follow this link to RVSpace:
GPIOs_Pinout_Information: https://rvspace.org/en/Product/General/StarFive_40-Pin_GPIO_Header_User_Guide
Installing some LibrariesFirst, install Gpiod library using the following command:
$ sudo pip install gpiod
Or you can try:
$ sudo dnf install gpiod
Then you need to install libgpiod library. Here this thing takes us on two ways path. We have to take both of them :) Firstly after gpiod isinstalled, we need to install the python3-libgpiod library. This was designed for python to access and manage gpios. So let's install it by using the following command.
$ sudo dnf install python3-libgpiod
after it is installed now we need to do the following commands "gpioinfo", "gpiodetect" to get info about our gpio but for that, we need to install another library. So install it by:
$ sudo dnf install libgpiod-utils
Now after this we can check it by the following command:
$ sudo gpiodetect
This command should show you the output with dierent gpiochips available on the board. More about that was already discussed.
Note: In my case, I have to install everything in this sequence otherwise it was giving me an error. I don't know why the hell but it was. So I had to uninstall all the libraries first and then install them in this sequence, or at least the solution that I figured out.
Fruit of Patience
Comments
Please log in or sign up to comment.