Python
Python
GUÍA DE PRÁCTICAS
import sys
import Tkinter
from Tkinter import *
import tkMessageBox
top=Tk()
top.title("LEDs")
#ENCENDIDO Y APAGADO DE LEDs
x=0
def led1():
global x
if x==1:
x=0
board.digital[5].write(1) #Enciende el led 1
else:
x=1
board.digital[5].write(0) #Apaga el led 1
def led2():
global x
if x==1:
x=0
board.digital[6].write(1) #Enciende el led 2
else:
x=1
board.digital[6].write(0) #Apaga el led 2
def led3():
global x
if x==1:
x=0
board.digital[7].write(1) # Enciende el led 3
else:
x=1
board.digital[7].write(0) #Apaga el led 3
UNIVERSIDAD NACIONAL DEL VERSIÓN: 1
CHIMBORAZO CÓDIGO: EET61
FACULTAD DE INGENIERIA
CARRERA DE ELECTRONICA Y PÁGINA: 1-6
TELECOMUNICACIONES
GUÍA DE PRÁCTICAS
it = util.Iterator(board)
it.start()
board.analog[0].enable_reporting() # Habilita pin A0
board.analog[1].enable_reporting() # Habilita pin A1
board.analog[2].enable_reporting() # Habilita pin A2
def Lectura():
leer1=board.analog[0].read() # Lee el dato A0
selection = "Valor = " + str(leer1)
label3.config(text = selection)
label3.place(x=220,y=10)
def Lectura2():
leer2=board.analog[1].read() # Lee el dato A1
selection = "Valor = " + str(leer2)
label4.config(text = selection)
label4.place(x=220,y=50) # Indica la posicion de texto
def Lectura3():
leer3=board.analog[2].read() # lee el dato A2
selection = "Valor = " + str(leer3)
label5.config(text = selection)
label5.place(x=220,y=90) # Indica la posicion de texto
GUÍA DE PRÁCTICAS
pin_8 = board.get_pin('d:8:s')
def servo(x): #funcion para el control de servo con slider
pin_8.write(x)
selection = "grados = "+ x
label.config(text=selection)
label.place(x=70,y=110)
scale = Scale(top,to=180, command = servo,bg="blue" ).place(x=70,y=10) #se crea el slider con un color
label = Label(top)
label.place(x=150,y=10) # posicion de texto
• Se creo un programa en Python en el cual se puede encender y apagar un led con un solo botón,
también se realizó la creación de botones para realizar lectura de pines analógicos, finalmente
se realizo un slider para el control de un servo.
Anexos:
GUÍA DE PRÁCTICAS
UNIVERSIDAD NACIONAL DEL VERSIÓN: 1
CHIMBORAZO CÓDIGO: EET61
FACULTAD DE INGENIERIA
CARRERA DE ELECTRONICA Y PÁGINA: 1-6
TELECOMUNICACIONES
GUÍA DE PRÁCTICAS
UNIVERSIDAD NACIONAL DEL VERSIÓN: 1
CHIMBORAZO CÓDIGO: EET61
FACULTAD DE INGENIERIA
CARRERA DE ELECTRONICA Y PÁGINA: 1-6
TELECOMUNICACIONES
GUÍA DE PRÁCTICAS