Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to control the RGB light of raspberry pie through WEB

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to control raspberry pie RGB lights through WEB". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to control raspberry pie RGB lights through WEB".

Main.py:

01 #! / usr/bin/env python302 03 import RPi.GPIO as GPIO04 from RGB_light import RGB_light05 from bottle import request, route, run, static_file # bottle introduction: https://git.oschina.net/ginnywzj/web_rgb/attach_files06 import time, threading07 08 rgb = 009 RGBLight = RGB_light (GPIO.BOARD, 1,33,35,37) # initialize rgb lamp GPIO pin, pin numbering system is GPIO.BOARD, common positive, red channel is 33 pin, green channel is 35 pin Blue channel is 37-pin s10 light_type = 'static' #' static': static 'breath': breath' flash': flashes 11 12 # access file root directory 13 @ route ('/') 14 def index (): 15 global rgb, light_type16 rgb = 0xffffff17 light_type = 'static'18 return static_file (' index.html' '. / page') 19 20 # static files need to be transferred 21 @ route (' /') 22 def server_static (filename): 23 return static_file (filename, root='./page') 24 25 # POST to obtain the RGB value 26 @ route ('/ rgb') transmitted by Ajax Method='POST') 27 def rgbLight (): 28 red= request.POST.get ('red') 29 green= request.POST.get (' green') 30 blue= request.POST.get ('blue') 31 print (' red='+ red +', green='+ green +', blue='+ blue) 32 red= int (red) 33 green= int (green) 34 blue= int (blue) 35 if 0 07

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report