PROGRAMA DE LA FOTORESISTENCIA CON UN FOCO DIBUJADO EN PYTHON

from turtle import *
import RPi.GPIO as GPIO, time
GPIO.setmode(GPIO.BCM)
#Main program loop
t=Turtle()
t2=Turtle()
screen=t.getscreen()
t.hideturtle()
colormode(255)
t.goto(0,0)

from turtle import*
t=Turtle()
t2=Turtle()
screen=t.getscreen()

setup(650,650,0,0)
screensize(120,120)
colormode(255)
t.hideturtle()
t2.hideturtle()
t.speed(9)

t.penup()
t2.dot(1000,200,200,200)

#Fondo
t.penup()
t.goto(-200,200)
t.pendown()
t.goto(-200,-200)
t.goto(200,-200)
t.goto(200,200)
t.goto(-200,200)
t.left(135)
t.fd(200)
t.penup()
t.back(200)
t.goto(-200,-200)
t.left(90)
t.pendown()
t.fd(200)
t.penup()
t.back(200)
t.goto(200,-200)
t.left(90)
t.pendown()
t.fd(200)
t.penup()
t.back(200)
t.goto(200,200)
t.pendown()
t.left(90)
t.fd(200)

#Foco

t.penup()
t.back(100)
t.left(135)
t.fd(275)
t.pensize(8)
t.left(90)
t.pendown()
t.forward(75)
t.left(90)
t.pensize(1)
t.fillcolor("gray")
t.begin_fill()
t.fd(12)
t.left(-90)
t.fd(15)
t.left(-90)
t.fd(25)
t.left(-90)
t.fd(15)
t.left(-90)
t.fd(12)
t.end_fill()
t.penup()
t.left(-90)
t.fd(35)
 #Color foco

while True:

#print RCtime(4) #Measure timing using GPIO4
measurement = 0
#Dischage capacitor
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, GPIO.LOW)
time.sleep(0.1)
GPIO.setup(4, GPIO.IN)
#Count loops until voltage across
#Capacitor reads high on GPIO
while (GPIO.input(4) == GPIO.LOW):
measurement += 1
print( measurement)
if measurement  >= 01  and measurement <= 999:
t.dot(40,255,0,0)
else:
if measurement >= 1000 and measurement <= 1999:
t.dot(40,255,25,25)
else:
if measurement >= 2000 and measurement <= 2999:
t.dot(40,255,50,50)
else:
if measurement >= 3000 and measurement <= 3999:
t.dot(40,255,100,100)
else:
if measurement >= 4000 and measurement <= 4999:
t.dot(40,255,125,125)
else:
if measurement >= 5000 and measurement <= 5999:
t.dot(40,255,150,150)
else:
if measurement >= 6000 and measurement <= 6999:
t.dot(40,255,175,175)
else:
if measurement >= 7000 and measurement <= 8999:
t.dot(40,255,200,200)
else:
if measurement >= 9000 and measurement <= 9999:
t.dot(40,255,255,225)
else:
if measurement >= 10000 and measurement <= 100000:
t.dot(40,255,255,255)




CAPTURAS:


Comentarios