STEM STUDY

Nghiên cứu & phát triển (R&D) về các lĩnh vực IoT, Robotics, Trí tuệ nhân tạo (AI), 3D Printing, ứng dụng website và các ứng dụng di động. Website: http://www.itr.com.vn

6. October 2018 20:46
by ĐÀO TƯỜNG SƠ
1 Comments

Raspberry Pi - Dự án 02: Điều chỉnh độ sáng tối của Led

6. October 2018 20:46 by ĐÀO TƯỜNG SƠ | 1 Comments

1. Linh kiện: giống dự án 01

2. Sơ đồ kết nối: giống dự án 01

3. Python Code: tạo file mới với tên led_brightness.py

import RPi.GPIO as GPIO


led_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)


pwm_led = GPIO.PWM(led_pin, 500)
pwm_led.start(100)


while True:
        duty_s = input("Enter Brightness (0 to 100): ")
        duty = int(duty_s)
        pwm_led.ChangeDutyCycle(duty)

4. Chạy chương trình:

sudo python led_brightness.py

 

Comments (1) -

Hello there I am so glad I found your webpage, I really found you by error, while I was searching on Bing for something else, Anyways I am here now and would just like to say kudos for a remarkable post and a all round thrilling blog (I also love the theme/design), I don't have time to go through it all at the minute but I have saved it and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the excellent job.

I go to see daily a few web pages and sites to read posts, however this web site provides quality based writing.

Add comment