Bonjour,
J’aurais besoin d’aide pour mon programme, Le truc c’est que lorsque j’allume il y a qu’une seule led (GPIO 23) qui s’allume progressivement et j’aimerais que ce soit les 4 (GPIO 18,17,27,23) qui s’allument progressivement. Est ce que vous savez ce que je dois rajouter ? ou modifier?
Merci beaucoup!
################################
##Generated with a lot of love##
with EasyPython
##Web site: easycoding.tn ##
################################
import RPi.GPIO as GPIO
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
from signal import signal, SIGINT
from sys import exit
Request = None
def handler(signal_received, frame):
# on g\u00e8re un cleanup propre
print(’’)
print(‹ SIGINT or CTRL-C detected. Exiting gracefully ›)
GPIO.cleanup()
exit(0)
GPIO init
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
50 Hz
p = GPIO.PWM(18, 50)
p = GPIO.PWM(17, 50)
p = GPIO.PWM(27, 50)
p = GPIO.PWM(23, 50)
cycle = 0%
p.start(0)
class RequestHandler_httpd(BaseHTTPRequestHandler):
def do_GET(self):
global Request
messagetosend = bytes(‹ Hello ›,« utf »)
self.send_response(200)
self.send_header(‹ Content-Type ›, ‹ text/plain ›)
self.send_header(‹ Content-Length ›, len(messagetosend))
self.end_headers()
self.wfile.write(messagetosend)
Request = self.requestline
Request = Request[5 : int(len(Request)-9)]
print(Request)
if Request == 'on':
GPIO.output(18, True)
GPIO.output(17, True)
GPIO.output(27, True)
GPIO.output(23, True)
for dc in range(0, 101, 1):
p.ChangeDutyCycle(dc)
time.sleep(0.10)
if Request == 'off':
GPIO.output(18, False)
GPIO.output(17, False)
GPIO.output(27, False)
GPIO.output(23, False)
for dc in range(100, -1, -1):
p.ChangeDutyCycle(dc)
time.sleep(0.05)
if Request == 'power':
return
server_address_httpd = (‹ 192.168.43.122 ›,8080)
httpd = HTTPServer(server_address_httpd, RequestHandler_httpd)
print(‹ Start Serveur ›)
httpd.serve_forever()
GPIO.cleanup()