wandboard gui

13
2012 Author: Praveen Kumar Controlling GPIO using GUI

Upload: praveen-rpk

Post on 13-Apr-2015

3.817 views

Category:

Documents


2 download

DESCRIPTION

This guide helps you to access gpio through the GUI.Here i am using python+tkinter module for gui.

TRANSCRIPT

Page 1: Wandboard GUI

2012

Author: Praveen Kumar

Controlling GPIO using GUI

Page 2: Wandboard GUI

# 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

# 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

# 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

# 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

# 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

# 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

# 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

# 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

# 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

# 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

# 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

# 9/3, 2nd floor, Sree Laksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

Email: [email protected], Phone: 080 - 26722726