Wandboard GUI
-
Upload
praveen-rpk -
Category
Documents
-
view
3.820 -
download
2
description
Transcript of Wandboard GUI
![Page 1: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/1.jpg)
2012
Author: Praveen Kumar
Controlling GPIO using GUI
![Page 2: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/2.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Tkinter:
The Tkinter module ("Tk interface") is the standard Python interface to the Tk GUI
toolkit from Scriptics (formerly developed by Sun Labs).
The former automatically imports the latter, so to use Tkinter, all you need to do is to
import one module:
import Tkinter
Or, more often:
from Tkinter import *
Let us see how to use this Tkinter for accessing GPIO pins in Wandboard.
Step 1:
Type the following command to activate Tkinter:
sudo apt-get install python python-tk idle python-pmw python-imaging
![Page 3: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/3.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Step 2:
You can download the library file from the below link
https://github.com/TenetTechnetronics/wandboardgpiolibrary
Copy library file to the desktop or any other directory.
Step 3:
Coding for accessing gpio with GUI using Tkinter
Open a terminal and type the following command for opening the editor with file name.
gediteditor window
.pypython extension
![Page 4: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/4.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Then type the following coding to access the gpio with gui.
#!/usr/bin/python
from Tkinter import *
import GPIO # importing GPIO library
led = 4 # assigning the gpio_4 to variable led
GPIO.export(led) # exporting the gpio_4
GPIO.setup(led,1) # make the gpio_4 as output pin by the value 1
def ledon(): # function for turning on an led
print "turn on"
GPIO.write(led,1)
def ledoff(): #function for turning off an led
print "turn off"
GPIO.write(led,0)
root =Tk()
![Page 5: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/5.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
button1 = Button(root,text="ON",command=ledon) #assigning the function ledon
to the button "ON"
button2 = Button(root,text="OFF",command=ledoff) #assigning the function ledoff
to the button "OFF"
button1.pack(side = LEFT ) #alignment for the button "ON"
button2.pack(side = RIGHT) #alignment for the button "OFF"
root.mainloop()
PINOUT:
![Page 6: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/6.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Sl.No Pin Number GPIO
1 GPIO75 GPIO_0
2 GPIO91 GPIO_1
3 GPIO191 GPIO_2
4 GPIO24 GPIO_3
5 GPIO200 GPIO_4
6 GPIO90 GPIO_5
7 GPIO72 GPIO_6
8 GPIO101 GPIO_7
JP4
![Page 7: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/7.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Step 5:
For example i am connecting an led to the gpio_4.
![Page 8: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/8.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Step 6:
Run your python file using the command below.
sudo python gui.py
guifile name
.py python extension
![Page 9: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/9.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Step 7:
Output window having the ON and OFF GUI
![Page 10: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/10.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
Step 8:
When you have click the button ON then the led will be turn on.
![Page 11: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/11.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
When you have the click the button OFF then the led will be turn off.
![Page 12: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/12.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726
For more details kindly go through the following link:
http://tenettech.com/category/265/wandboard
http://blogspot.tenettech.com/
http://www.youtube.com/watch?v=5UmTDIUIRBs&feature=share&list=UUyRZXnQe
h8xgmgDYxQfN8eA
https://github.com/TenetTechnetronics/wandboardgpiolibrary
![Page 13: Wandboard GUI](https://reader030.fdocuments.us/reader030/viewer/2022020101/552c65934a7959eb7c8b477e/html5/thumbnails/13.jpg)
# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,
Email: [email protected], Phone: 080 - 26722726