Swapnanil Paul
Published © GPL3+

Remotely Led Control using Boltiot and Python

Here we create some basic operation of Leds using python and Bolt Iot wifi module.

BeginnerShowcase (no instructions)2 hours400
Remotely Led Control using Boltiot and Python

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Story

Read more

Code

Led-control code

Python
import tkinter
from tkinter import *
from boltiot import Bolt
import json

# Basic structure of the GUI

root = tkinter.Tk()
root.geometry("450x350+300+300")
root.resizable(0,0)
root.title("Led Control System")

# your devic info

API_key = "Your API key"
Device_ID = "Your Device Id"

mybolt = Bolt(API_key,Device_ID)

mybolt.digitalWrite('0','LOW')


def lightson():
   response=mybolt.isOnline()
   data=json.loads(response)
   if data["value"]=="online":
       mybolt.digitalWrite('0','HIGH')#0 is the gpio pin
   else:
       print("Your device is offline")


def lightsoff():
   res=mybolt.isOnline()
   data=json.loads(res)
   if data["value"]=="online":
       mybolt.digitalWrite('0','LOW')
   else:
       print("Your device is offline")


def Control():
    res=mybolt.isOnline()
    data=json.loads(res)
    v = area.get()
    if data["value"]=="online":
       mybolt.analogWrite('0', v)
    else:
       print("Your device is offline")

# python tkinter GUI design

lbl1 = Label (root, text = "Control The LED", anchor = N, font = ("roboto", 20, "bold underline"),fg = "blue")
lbl1.pack(expand = True, fill = "both",pady = "10px")

btn1 = Button (root, text = "Lights On",bd = 4, font = ("Vardana", 10, "bold"),bg = "#5dff5d", command=lightson)
btn1.pack()

btn2 = Button (root, text = "Lights Off",bd = 4, font = ("Vardana", 10, "bold"),bg = "#f12e51", command=lightsoff)
btn2.pack(pady = "20")

lbl2 = Label (root, text = "Control the brightness lever of the LED", font = ("Arial ", 16, "bold underline"),fg = "blue")
lbl2.pack(expand = True, fill = "both")

lbl3 = Label (root, text = "Enter value between 1 to 254", font = ("Arial",12,"bold"),fg = "red")
lbl3.pack(expand = True, fill = "both")

area = Entry (root)
area.pack()

btn3 = Button (root, text = "Ok",bd = 3, font = ("Vardana"), bg = "#4afae5", command=Control)
btn3.pack(pady = "20")




root.mainloop()

Credits

Swapnanil Paul
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.