wandboard gui

Post on 13-Apr-2015

3.820 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

2012

Author: Praveen Kumar

Controlling GPIO using GUI

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

Email: info@tenettech.com, 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

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

Email: info@tenettech.com, 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

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

Email: info@tenettech.com, 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()

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

Email: info@tenettech.com, 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:

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

Email: info@tenettech.com, 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

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

Email: info@tenettech.com, Phone: 080 - 26722726

Step 5:

For example i am connecting an led to the gpio_4.

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

Email: info@tenettech.com, Phone: 080 - 26722726

Step 6:

Run your python file using the command below.

sudo python gui.py

guifile name

.py python extension

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

Email: info@tenettech.com, Phone: 080 - 26722726

Step 7:

Output window having the ON and OFF GUI

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

Email: info@tenettech.com, Phone: 080 - 26722726

Step 8:

When you have click the button ON then the led will be turn on.

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

Email: info@tenettech.com, Phone: 080 - 26722726

When you have the click the button OFF then the led will be turn off.

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

Email: info@tenettech.com, 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

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

Email: info@tenettech.com, Phone: 080 - 26722726

top related