Rohith Reddy
Published

Auto adjust your computer screen brightness

Using a Light Dependent Resistor(LDR) with bolt IoT module adjust the computer screen brightness based on rooms brightness.

BeginnerFull instructions provided2 hours167
Auto adjust your computer screen brightness

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Personal Computer
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 330 ohm
Resistor 330 ohm
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Ubuntu
VS Code
Microsoft VS Code
Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

circuit diagram

Code

Code to automated brightness control

Python
1.Here I have imported boltiot ,screen_brightness_control,conf,json,time python modules. You may need to install them before running the code.
2.I have set the brightness conditions to my comfort,You can change the values or add new conditions.
3.I have set the frequency of reading the LDR value to 5 seconds , you can change it accordingly.
import conf, json, time
from boltiot import  Bolt
#below package needs to be downloaded before using it
#link - https://pypi.org/project/screen-brightness-control/
import screen_brightness_control as sbc

mybolt=Bolt(conf.API_KEY,conf.DEVICE_ID)
while True: 
    print ("Reading sensor value")
    response = mybolt.analogRead('A0') 
    data = json.loads(response) 
    data_val = int(data['value'])
    if(data_val <100):
        sbc.set_brightness(10)
    elif(data_val < 500):
        sbc.set_brightness(50)
    elif(data_val < 700):
        sbc.set_brightness(70)
    elif(data_val < 900):
        sbc.set_brightness(90)
    else:
        sbc.set_brightness(100)
    print("Sensor value is: " + str(data_val))
    print("Screen Brightness is: " + str(sbc.get_brightness()))
    time.sleep(5)

Credits

Rohith Reddy

Rohith Reddy

1 project • 0 followers

Comments