loading
Led calculator is a simple GUI written using python2.7. is a simple application to calculate the value of the resistor in a series LED circuit. this can also help to understand the basic features of TKinter if you are new in to Python

Step 1: Geany

since iam using ubuntu, working with geany is  awsome

Step 2: The CODE

#  Author : Mohamad Sigit Dude
#  Python: 2.7
#  www.tokolampugorontalo.blogspot.com
#  www.makebot.blogspot.com
#  Dudelectric-microsystems
#  Gorontalo 06-21-2013
###################################################
from Tkinter import *

def hapus(entry1,entry2,entry3,entry4,entry5):
    entry1.delete(0, END)
    entry2.delete(0,END)
    entry3.delete(0, END)
    entry4.delete(0,END)
    entry5.delete(0,END)
 
def hitungan(entry5):
sv=int(entry1.get())
lv=int(entry2.get())
hm=int(entry3.get())
dc=int(entry4.get())
op=(sv-(lv*hm))/(float(dc)/1000)
e.set("%.1f" % op)
 
window = Tk()
root = Frame(window)
root.pack()

label1 = Label(root, text="Supply voltage (V) ")
label1.pack(side="left")
entry1 = Entry(root,width=3,foreground="red"  )
entry1.pack(side="left")

label2 = Label(root, text="Led Volt (V)")
label2.pack(side="left")
entry2 = Entry(root,width=3,foreground="purple")
entry2.pack(side="left")

label3 = Label(root, text="How many leds ")
label3.pack(side="left")
entry3 = Entry(root,width=3,foreground="blue")
entry3.pack(side="left")

label4 = Label(root, text="Desired Current (mA) ")
label4.pack(side="left")
entry4 = Entry(root,width=4,foreground="orange")
entry4.pack(side="left")

label5 = Label(root, text="RESISTOR VALUE (ohm)")
label5.pack(side="left")
e=StringVar()
entry5 = Entry(root,width=10,background="cyan",highlightcolor="red",foreground="red",textvariable=e)
entry5.pack(side="left")

button1 = Button(text="GET VALUE",command=lambda:hitungan(entry5)).pack(side=RIGHT)
button2 = Button(text="Clear All",command=lambda:hapus(entry1,entry2,entry3,entry4,entry5)).pack(side=BOTTOM)


window.mainloop()

About This Instructable

1,485views

6favorites

License:

Bio: Bismillah..
More by dudelectric:Python LED Calculator PUNKDUINO 
Add instructable to: