In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use webiopi web pages to control LED. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Webiopi is a web framework that can control the raspberry pie GPIO, which is developed for the IoT of the Internet of things. The project is hosted on google and the source code can be downloaded on sourceforge. Now that webiopi has grown to version 0. 7, webiopi supports REST Server,CoAP server and provides python libraries and javascript libraries. There is no doubt that webiopi is an excellent framework.
Although webiopi is an excellent framework, webiopi is written in python,javacript language and provides access in the form of REST and CoAP. Learning and mastering webiopi requires a lot of basic knowledge. For embedded engineers who think that C, register manipulation, and hexadecimal protocols can solve everything, python and javacript,REST and CoAP protocols are bloated and useless. But this is not the case.
[the difference between webiopi and other web page control LED]
1. In the background, the perfect RESTAPI can realize the direction control, output control and input detection of GPIO port.
two。 Foreground, complete javascript API, convenient for users to create tags and connect with the background API.
1. Installation of webiopi
Download the latest webiopi and upload it to raspberry pie, then extract and install it
[code]
Tar xvzf WebIOPi-0.7.1.tar.gz
Cd WebIOPi-0.7.1
Sudo. / setup.sh
[/ code]
The installation process takes some time, and webiopi automatically installs some of the necessary software and resolves dependencies.
Second, test whether the installation is successful
You can enter the following commands:
[code]
Webiopi-h
[/ code]
If the installation is successful, the following prompt appears:
3. Run webiopi
Enter the following instructions to run webiopi
[code]
Sudo webiopi-d-c / etc/webiopi/config
[/ code]
[description]
-d means to turn on debug mode, and when you run webiopi, you will output some information in the console.
-c represents the configuration file, the path to the configuration file is / etc/webiopi/config, and what is in the configuration file, which will be analyzed in a later blog.
If the port of webiopi is not set for the port, the default value of the port number is 8000
Enter the IP address of the raspberry pie in the browser, for example, 192.168.1.107VR 8000.
A login window will pop up first, and the user name and password need to be set. The user name defaults to webiopi and the default password is raspberry.
The main interface is like this
Click GPIO Header to enter
You can view the status of GPIO pins
4. Complete the web page control LED
After installing webiopi, the home directory of webiopi is / usr/share/webiopi/htdocs, and the index.html file in the htdoc directory is the navigation interface above.
Now let's upload the html file to this directory and name it myindex.html with the following contents:
WebIOPi | Demo webiopi () .ready (function () {/ / GPIO24 and GPIO17 are output webiopi () .setFunction (24, "out"); webiopi () .setFunction (17, "out"); var content, button; content = $("# content") / / create a different button, the button ID is hold, the name is LED1, and bind the press and release event button = webiopi (). CreateButton ("hold", "LED1", mousedown, mouseup); content.append (button); / / create a GPIO button numbered GPIO17, the button name is LED2 button = webiopi () .createGPIOButton (17, "LED2"); content.append (button) / / append button to content div / / does not automatically refresh the interface webiopi () .refreshGPIO (false);}); function mousedown () {/ / GPIO24 output high level webiopi () .digitalWrite (24,1);} function mouseup () {/ / GPIO24 output low level webiopi () .digitalWrite (24,0) } button {display: block; margin: 5px 5px 5px 5px; width: 160px; height: 45px; font-size: 24pt; font-weight: bold; color: black;} .LOW {background-color: White } .HIGH {background-color: Red;}
My physical connection is like this: connect the negative pole of the LED lamp to pin 6, and the negative electrode to pin 11 (GPIO 17). Do not use professional graphics tools to draw, do not spray
Enter the following instructions to run the program:
[code]
Sudo webiopi-c config
[/ code]
Enter the IP address and port number in the browser: 172.16.2.222purl 8000
Final effect: press LED2 to light up, then press the following to extinguish
On how to use webiopi web pages to control LED to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.