Python - Semaforo
En el siguiente se muestra una glorieta, con interfaz grafica y física
import RPi.GPIO as gpio
from turtle import*
import turtle
import time
t=Turtle()
a=Turtle()
b=Turtle()
c=Turtle()
d=Turtle()
l0=Turtle()
l1=Turtle()
l2=Turtle()
l3=Turtle()
l4=Turtle()
l5=Turtle()
l6=Turtle()
l7=Turtle()
l8=Turtle()
l9=Turtle()
l10=Turtle()
setup(1350,680,0,0)
title("Glorieta")
turtle.bgcolor("black")
t.hideturtle()
a.hideturtle()
b.hideturtle()
c.hideturtle()
d.hideturtle()
t.speed(30)
a.speed(30)
b.speed(30)
c.speed(30)
d.speed(30)
#OXXO
t.penup()
t.goto(-660, -100)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(400)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(80)
t.right(90)
t.fd(550)
t.right(90)
t.fd(230)
t.end_fill()
#B1
t.penup()
t.goto(-660, -10)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.right(90)
t.fd(400)
t.left(90)
t.fd(20)
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.end_fill()
#ACTAS
t.penup()
t.goto(-110, 330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(80)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(400)
t.right(90)
t.fd(230)
t.right(90)
t.fd(550)
t.end_fill()
#B2
t.penup()
t.goto(-10, 330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(20)
t.right(90)
t.fd(80)
t.right(90)
t.fd(20)
t.right(90)
t.fd(80)
t.right(90)
t.end_fill()
#PALACIO
t.penup()
t.goto(110,330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(550)
t.right(90)
t.fd(230)
t.right(90)
t.fd(400)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(80)
t.end_fill()
#B3
t.penup()
t.goto(660, 10)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.end_fill()
#KRISTAL
t.penup()
t.goto(660, -330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(550)
t.right(90)
t.fd(80)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(400)
t.end_fill()
#B4
t.penup()
t.goto(10, -330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(80)
t.left(90)
t.fd(20)
t.left(90)
t.fd(80)
t.left(90)
t.fd(20)
t.end_fill()
#GLORIETA
t.penup()
t.home()
t.goto(140,0)
t.pendown()
t.left(90)
t.fillcolor("gray")
t.begin_fill()
t.circle(140,360,60)
t.end_fill()
t.penup()
t.goto(100,0)
t.pendown()
t.fillcolor("steelblue1")
t.begin_fill()
t.circle(100,360,60)
t.end_fill()
t.penup()
t.home()
t.pendown()
t.fillcolor("thistle1")
t.begin_fill()
for i in range(5):
t.circle(30,360,30)
t.left(72)
t.end_fill()
#LINEAS AMARILLAS
t.penup()
t.goto(20,-252)
t.pendown()
t.pensize(8)
t.pencolor("gold")
t.goto(20,-275)
t.penup()
t.goto(35,-252)
t.pendown()
t.goto(35,-275)
t.penup()
t.goto(50,-252)
t.pendown()
t.goto(50,-275)
t.penup()
t.goto(65,-252)
t.pendown()
t.goto(65,-275)
t.penup()
t.goto(80,-252)
t.pendown()
t.goto(80,-275)
t.penup()
t.goto(95,-252)
t.pendown()
t.goto(95,-275)
t.penup()
t.goto(-20,252)
t.pendown()
t.goto(-20,272)
t.penup()
t.goto(-35,252)
t.pendown()
t.goto(-35,272)
t.penup()
t.goto(-50,252)
t.pendown()
t.goto(-50,272)
t.penup()
t.goto(-65,252)
t.pendown()
t.goto(-65,272)
t.penup()
t.goto(-80,252)
t.pendown()
t.goto(-80,272)
t.penup()
t.goto(-95,252)
t.pendown()
t.goto(-95,272)
t.penup()
t.goto(-260,-20)
t.pendown()
t.goto(-280,-20)
t.penup()
t.goto(-260,-35)
t.pendown()
t.goto(-280,-35)
t.penup()
t.goto(-260,-50)
t.pendown()
t.goto(-280,-50)
t.penup()
t.goto(-260,-65)
t.pendown()
t.goto(-280,-65)
t.penup()
t.goto(-260,-80)
t.pendown()
t.goto(-280,-80)
t.penup()
t.goto(-260,-95)
t.pendown()
t.goto(-280,-95)
t.penup()
t.goto(260, 20)
t.pendown()
t.goto(280,20)
t.penup()
t.goto(260,35)
t.pendown()
t.goto(280,35)
t.penup()
t.goto(260,50)
t.pendown()
t.goto(280,50)
t.penup()
t.goto(260,65)
t.pendown()
t.goto(280,65)
t.penup()
t.goto(260,80)
t.pendown()
t.goto(280,80)
t.penup()
t.goto(260,95)
t.pendown()
t.goto(280,95)
#SEMAFORO 1
#CAJA
a.penup()
a.goto(115, -300)
a.pendown()
a.fillcolor("gray66")
a.begin_fill()
a.forward(40)
a.left(90)
a.forward(84)
a.left(90)
a.forward(40)
a.left(90)
a.forward(84)
a.end_fill()
#BASE
a.fillcolor("black")
a.begin_fill()
a.left(90)
a.fd(15)
a.right(90)
a.fd(20)
a.left(90)
a.fd(10)
a.left(90)
a.fd(20)
a.left(90)
a.fd(10)
a.end_fill()
a.penup()
a.goto(144,-320)
a.pendown()
a.fillcolor("black")
a.begin_fill()
a.right(90)
a.circle(8.8,180,15)
a.left(90)
a.fd(17.6)
a.end_fill()
a.penup()
#LUCES
a.penup()
a.goto(135,-290)
a.pendown()
a.fillcolor("red4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.left(90)
a.penup()
a.fd(22)
a.right(90)
a.pendown()
a.fillcolor("yellow4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.left(90)
a.penup()
a.fd(22)
a.right(90)
a.pendown()
a.fillcolor("green4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
#SEMAFORO 2
#CAJA
b.penup()
b.goto(320, 110)
b.pendown()
b.left(180)
b.fillcolor("gray66")
b.begin_fill()
b.fd(84)
b.right(90)
b.fd(40)
b.right(90)
b.fd(84)
b.right(90)
b.fd(40)
b.end_fill()
#BASE
b.left(180)
b.fd(15)
b.fillcolor("black")
b.begin_fill()
b.right(90)
b.fd(20)
b.left(90)
b.fd(10)
b.left(90)
b.fd(20)
b.end_fill()
b.penup()
b.goto(340,139)
b.pendown()
b.fillcolor("black")
b.begin_fill()
b.circle(8.8,180,15)
b.left(90)
b.fd(17.6)
b.end_fill()
#LUCES
b.penup()
b.goto(265, 130)
b.pendown()
b.fillcolor("green4")
b.begin_fill()
b.circle(10,360,15)
b.right(90)
b.end_fill()
b.penup()
b.fd(2)
b.pendown()
b.fillcolor("yellow4")
b.begin_fill()
b.right(90)
b.circle(10,360,15)
b.left(90)
b.end_fill()
b.penup()
b.fd(22)
b.pendown()
b.fillcolor("red4")
b.begin_fill()
b.right(90)
b.circle(10,360,15)
b.end_fill()
#SEMAFORO 3
#CAJA
c.penup()
c.goto(-115, 300)
c.pendown()
c.fillcolor("gray66")
c.begin_fill()
c.right(90)
c.fd(84)
c.right(90)
c.fd(40)
c.right(90)
c.fd(84)
c.right(90)
c.fd(40)
c.end_fill()
c.left(180)
#BASE
c.fd(15)
c.right(90)
c.fillcolor("black")
c.begin_fill()
c.fd(20)
c.left(90)
c.fd(10)
c.left(90)
c.fd(20)
c.end_fill()
c.penup()
c.goto(-144, 320)
c.pendown()
c.fillcolor("black")
c.begin_fill()
c.circle(8.8,180,15)
c.left(90)
c.fd(17.6)
c.end_fill()
#LUCES
c.penup()
c.goto(-135, 245)
c.pendown()
c.fillcolor("green4")
c.begin_fill()
c.circle(10,360,15)
c.end_fill()
c.right(90)
c.penup()
c.fd(2)
c.right(90)
c.pendown()
c.fillcolor("yellow4")
c.begin_fill()
c.circle(10,360,15)
c.end_fill()
c.penup()
c.left(90)
c.fd(22)
c.pendown()
c.fillcolor("red4")
c.begin_fill()
c.right(90)
c.circle(10,360,15)
c.end_fill()
#SEMAFORO 4
#CAJA
d.penup()
d.goto(-320,-105)
d.pendown()
d.fillcolor("gray66")
d.begin_fill()
d.fd(84)
d.right(90)
d.fd(40)
d.right(90)
d.fd(84)
d.right(90)
d.fd(40)
d.end_fill()
#BASE
d.left(180)
d.fd(15)
d.right(90)
d.fillcolor("black")
d.begin_fill()
d.fd(20)
d.left(90)
d.fd(10)
d.left(90)
d.fd(20)
d.end_fill()
d.penup()
d.goto(-340,-134)
d.pendown()
d.fillcolor("black")
d.begin_fill()
d.circle(8.8,180,15)
d.left(90)
d.fd(17.6)
d.end_fill()
#LUCES
d.penup()
d.goto(-265,-125)
d.pendown()
d.fillcolor("green4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
d.right(90)
d.penup()
d.fd(2)
d.pendown()
d.right(90)
d.fillcolor("yellow4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
d.penup()
d.left(90)
d.fd(22)
d.pendown()
d.right(90)
d.fillcolor("red4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
h0=[0, 8]
h05=[0,9]
h1=[1, 9]
h2=[2,10]
h3=[3,11]
h4=[4,12]
h5=[5,13]
h6=[6,14]
h7=[7,16]
#SEM1
l0.hideturtle()
l0.home()
l0.color("purple")
l0.shapesize(2,2,2)
l0.shape("turtle")
l0.speed(0.5)
l0.penup()
l0.goto(55,-300)
l0.left(90)
l0.showturtle()
l1.hideturtle()
l1.home()
l1.color("red")
l1.shapesize(2,2,2)
l1.shape("turtle")
l1.speed(0.5)
l1.penup()
l1.goto(55,-350)
l1.left(90)
l1.showturtle()
#SEM2
l2.hideturtle()
l2.home()
l2.color("red")
l2.shapesize(2,2,2)
l2.shape("turtle")
l2.speed(0.5)
l2.penup()
l2.goto(-320,-55)
l2.showturtle()
l3.hideturtle()
l3.home()
l3.color("red")
l3.shapesize(2,2,2)
l3.shape("turtle")
l3.speed(0.5)
l3.penup()
l3.goto(-380,-55)
l3.showturtle()
l4.hideturtle()
l4.home()
l4.color("red")
l4.shapesize(2,2,2)
l4.shape("turtle")
l4.speed(0.5)
l4.penup()
l4.goto(-440,-55)
l4.showturtle()
#SEM3
l5.hideturtle()
l5.home()
l5.color("red")
l5.shapesize(2,2,2)
l5.shape("turtle")
l5.speed(0.5)
l5.penup()
l5.goto(-55,300)
l5.right(90)
l5.showturtle()
l6.hideturtle()
l6.home()
l6.color("red")
l6.shapesize(2,2,2)
l6.shape("turtle")
l6.speed(0.5)
l6.penup()
l6.goto(-55,350)
l6.right(90)
l6.showturtle()
#SEM4
l7.hideturtle()
l7.home()
l7.color("red")
l7.shapesize(2,2,2)
l7.shape("turtle")
l7.speed(0.5)
l7.penup()
l7.left(180)
l7.goto(320,55)
l7.showturtle()
l8.hideturtle()
l8.home()
l8.color("red")
l8.shapesize(2,2,2)
l8.shape("turtle")
l8.speed(0.5)
l8.penup()
l8.left(180)
l8.goto(380,55)
l8.showturtle()
l9.hideturtle()
l9.home()
l9.color("red")
l9.shapesize(2,2,2)
l9.shape("turtle")
l9.speed(0.5)
l9.penup()
l9.left(180)
l9.goto(440,55)
l9.showturtle()
l10.hideturtle()
l10.home()
l10.color("red")
l10.shapesize(2,2,2)
l10.shape("turtle")
l10.speed(0.5)
l10.penup()
l10.left(180)
l10.goto(500,55)
l10.showturtle()
gpio.setmode(gpio.BOARD)
gpio.setup(3, gpio.OUT)
gpio.setup(5, gpio.OUT)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
gpio.setup(19, gpio.OUT)
gpio.setup(21, gpio.OUT)
gpio.setup(23, gpio.OUT)
gpio.setup(29, gpio.OUT)
gpio.setup(31, gpio.OUT)
gpio.setup(33, gpio.OUT)
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.LOW)
time.sleep(2)
x=0
while (x<16):
if x in h0:
time.sleep(1)
v1="green2"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red4"
r2="red"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.HIGH)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l7.hideturtle()
l7.speed(0.5)
l7.home()
l7.color("red")
l7.shapesize(2,2,2)
l7.shape("turtle")
l7.speed(0.5)
l7.penup()
l7.left(180)
l7.goto(320,55)
l7.showturtle()
l8.hideturtle()
l8.speed(0.5)
l8.home()
l8.color("red")
l8.shapesize(2,2,2)
l8.shape("turtle")
l8.penup()
l8.left(180)
l8.goto(380,55)
l8.showturtle()
l9.hideturtle()
l9.speed(0.5)
l9.home()
l9.color("red")
l9.shapesize(2,2,2)
l9.shape("turtle")
l9.penup()
l9.left(180)
l9.goto(440,55)
l9.showturtle()
l10.hideturtle()
l10.speed(0.5)
l10.home()
l10.color("red")
l10.shapesize(2,2,2)
l10.shape("turtle")
l10.penup()
l10.left(180)
l10.goto(500,55)
l10.showturtle()
if x==8:
x=x+1
#x=x+1
elif x in h1:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red4"
r2="red"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.HIGH)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
x=x+1
elif x in h2:
time.sleep(1)
v1="green4"
v2="green2"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red4"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.HIGH)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l0.hideturtle()
l0.speed(0.5)
l0.home()
l0.color("purple")
l0.shapesize(2,2,2)
l0.shape("turtle")
l0.penup()
l0.goto(55,-300)
l0.left(90)
l0.showturtle()
l1.hideturtle()
l1.speed(0.5)
l1.home()
l1.color("red")
l1.shapesize(2,2,2)
l1.shape("turtle")
l1.penup()
l1.goto(55,-350)
l1.left(90)
l1.showturtle()
x=x+1
elif x in h3:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red4"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.HIGH)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(23, gpio.HIGH)
x=x+1
elif x in h4:
time.sleep(1)
v1="green4"
v2="green4"
v3="green2"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red"
r3="red4"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.HIGH)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l2.hideturtle()
l2.speed(0.5)
l2.home()
l2.color("red")
l2.shapesize(2,2,2)
l2.shape("turtle")
l2.penup()
l2.goto(-320,-55)
l2.showturtle()
l3.hideturtle()
l3.speed(0.5)
l3.home()
l3.color("red")
l3.shapesize(2,2,2)
l3.shape("turtle")
l3.penup()
l3.goto(-380,-55)
l3.showturtle()
l4.hideturtle()
l4.speed(0.5)
l4.home()
l4.color("red")
l4.shapesize(2,2,2)
l4.shape("turtle")
l4.penup()
l4.goto(-440,-55)
l4.showturtle()
x=x+1
elif x in h5:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow"
a4="yellow4"
r1="red"
r2="red"
r3="red4"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.HIGH)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
x=x+1
elif x in h6:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green2"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red"
r3="red"
r4="red4"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.HIGH)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.LOW)
l5.hideturtle()
l5.home()
l5.speed(0.5)
l5.color("red")
l5.shapesize(2,2,2)
l5.shape("turtle")
l5.penup()
l5.goto(-55,300)
l5.right(90)
l5.showturtle()
l6.hideturtle()
l6.speed(0.5)
l6.home()
l6.color("red")
l6.shapesize(2,2,2)
l6.shape("turtle")
l6.penup()
l6.goto(-55,350)
l6.right(90)
l6.showturtle()
if x == 14:
break
x=x+1
elif x in h7:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow"
r1="red"
r2="red"
r3="red"
r4="red4"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.HIGH)
gpio.output(33, gpio.LOW)
x=x+1
a.penup()
a.goto(135,-246)
a.pendown()
a.fillcolor(v1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.penup()
a.goto(135,-268)
a.pendown()
a.fillcolor(a1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.penup()
a.goto(135,-290)
a.pendown()
a.fillcolor(r1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
d.penup()
d.home()
d.goto(-255,-115)
d.fillcolor(v2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
d.penup()
d.home()
d.goto(-277,-115)
d.fillcolor(a2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
d.penup()
d.home()
d.goto(-299,-115)
d.fillcolor(r2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
c.penup()
c.home()
c.goto(-135, 245)
c.pendown()
c.fillcolor(v3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
c.penup()
c.home()
c.goto(-135, 267)
c.pendown()
c.fillcolor(a3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
c.penup()
c.home()
c.goto(-135, 289)
c.pendown()
c.fillcolor(r3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
b.penup()
b.home()
b.goto(255, 140)
b.pendown()
b.fillcolor(v4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
b.penup()
b.home()
b.goto(277, 140)
b.pendown()
b.fillcolor(a4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
b.penup()
b.home()
b.goto(299, 140)
b.pendown()
b.fillcolor(r4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
if x in h7:
l7.speed(2)
l8.speed(2)
l9.speed(2)
l10.speed(2)
l7.fd(90)
l8.fd(90)
l9.fd(90)
l10.fd(90)
l7.right(90)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.right(90)
l8.fd(60)
l9.fd(60)
l10.fd(60)
l7.fd(500)
l8.right(90)
l8.circle(150,90,10)
l8.fd(100)
l8.circle(150,80,10)
l8.fd(100)
l8.circle(150,90,10)
l8.right(80)
l9.fd(60)
l10.fd(60)
l8.fd(200)
l9.right(90)
l9.circle(150,90,10)
l9.fd(100)
l9.circle(150,90,10)
l9.right(90)
l10.fd(60)
l10.right(80)
l10.circle(150,80,10)
l10.right(90)
l9.fd(600)
l10.fd(200)
#x=x+1
if x in h5:
l5.speed(2)
l6.speed(2)
l5.fd(90)
l6.fd(90)
l5.right(90)
l5.circle(150,90,10)
l5.right(90)
l5.fd(600)
l6.fd(60)
l6.right(90)
l6.circle(150,90,10)
l6.right(90)
l6.fd(600)
#x=x+1
if x in h3:
l2.speed(2)
l3.speed(2)
l4.speed(2)
l2.fd(90)
l3.fd(90)
l4.fd(90)
l2.right(90)
l2.circle(150,90,10)
l2.fd(100)
l2.circle(150,90,10)
l2.fd(100)
l2.circle(150,80,10)
l2.right(80)
l3.fd(60)
l4.fd(60)
l3.right(90)
l3.circle(150,90,10)
l3.fd(100)
l3.circle(150,90,10)
l3.right(90)
l4.fd(60)
l4.right(90)
l4.circle(150,90,10)
l4.right(90)
l2.fd(200)
l3.fd(600)
l4.fd(200)
#x=x+1
if x in h05:
l0.speed(2)
l1.speed(2)
l0.fd(120)
l1.fd(80)
l0.right(90)
l0.circle(150,80,10)
l0.right(80)
l0.fd(500)
l1.fd(50)
l1.right(90)
l1.circle(150,90,10)
l1.fd(100)
l1.circle(150,90,10)
l1.right(90)
l1.fd(200)
x=x+1
import RPi.GPIO as gpio
from turtle import*
import turtle
import time
t=Turtle()
a=Turtle()
b=Turtle()
c=Turtle()
d=Turtle()
l0=Turtle()
l1=Turtle()
l2=Turtle()
l3=Turtle()
l4=Turtle()
l5=Turtle()
l6=Turtle()
l7=Turtle()
l8=Turtle()
l9=Turtle()
l10=Turtle()
setup(1350,680,0,0)
title("Glorieta")
turtle.bgcolor("black")
t.hideturtle()
a.hideturtle()
b.hideturtle()
c.hideturtle()
d.hideturtle()
t.speed(30)
a.speed(30)
b.speed(30)
c.speed(30)
d.speed(30)
#OXXO
t.penup()
t.goto(-660, -100)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(400)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(80)
t.right(90)
t.fd(550)
t.right(90)
t.fd(230)
t.end_fill()
#B1
t.penup()
t.goto(-660, -10)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.right(90)
t.fd(400)
t.left(90)
t.fd(20)
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.end_fill()
#ACTAS
t.penup()
t.goto(-110, 330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(80)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(400)
t.right(90)
t.fd(230)
t.right(90)
t.fd(550)
t.end_fill()
#B2
t.penup()
t.goto(-10, 330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(20)
t.right(90)
t.fd(80)
t.right(90)
t.fd(20)
t.right(90)
t.fd(80)
t.right(90)
t.end_fill()
#PALACIO
t.penup()
t.goto(110,330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.fd(550)
t.right(90)
t.fd(230)
t.right(90)
t.fd(400)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(80)
t.end_fill()
#B3
t.penup()
t.goto(660, 10)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.left(90)
t.fd(400)
t.left(90)
t.fd(20)
t.end_fill()
#KRISTAL
t.penup()
t.goto(660, -330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(550)
t.right(90)
t.fd(80)
t.right(90)
t.circle(150,90,15)
t.right(90)
t.fd(400)
t.end_fill()
#B4
t.penup()
t.goto(10, -330)
t.fillcolor("gray")
t.begin_fill()
t.pendown()
t.left(90)
t.fd(80)
t.left(90)
t.fd(20)
t.left(90)
t.fd(80)
t.left(90)
t.fd(20)
t.end_fill()
#GLORIETA
t.penup()
t.home()
t.goto(140,0)
t.pendown()
t.left(90)
t.fillcolor("gray")
t.begin_fill()
t.circle(140,360,60)
t.end_fill()
t.penup()
t.goto(100,0)
t.pendown()
t.fillcolor("steelblue1")
t.begin_fill()
t.circle(100,360,60)
t.end_fill()
t.penup()
t.home()
t.pendown()
t.fillcolor("thistle1")
t.begin_fill()
for i in range(5):
t.circle(30,360,30)
t.left(72)
t.end_fill()
#LINEAS AMARILLAS
t.penup()
t.goto(20,-252)
t.pendown()
t.pensize(8)
t.pencolor("gold")
t.goto(20,-275)
t.penup()
t.goto(35,-252)
t.pendown()
t.goto(35,-275)
t.penup()
t.goto(50,-252)
t.pendown()
t.goto(50,-275)
t.penup()
t.goto(65,-252)
t.pendown()
t.goto(65,-275)
t.penup()
t.goto(80,-252)
t.pendown()
t.goto(80,-275)
t.penup()
t.goto(95,-252)
t.pendown()
t.goto(95,-275)
t.penup()
t.goto(-20,252)
t.pendown()
t.goto(-20,272)
t.penup()
t.goto(-35,252)
t.pendown()
t.goto(-35,272)
t.penup()
t.goto(-50,252)
t.pendown()
t.goto(-50,272)
t.penup()
t.goto(-65,252)
t.pendown()
t.goto(-65,272)
t.penup()
t.goto(-80,252)
t.pendown()
t.goto(-80,272)
t.penup()
t.goto(-95,252)
t.pendown()
t.goto(-95,272)
t.penup()
t.goto(-260,-20)
t.pendown()
t.goto(-280,-20)
t.penup()
t.goto(-260,-35)
t.pendown()
t.goto(-280,-35)
t.penup()
t.goto(-260,-50)
t.pendown()
t.goto(-280,-50)
t.penup()
t.goto(-260,-65)
t.pendown()
t.goto(-280,-65)
t.penup()
t.goto(-260,-80)
t.pendown()
t.goto(-280,-80)
t.penup()
t.goto(-260,-95)
t.pendown()
t.goto(-280,-95)
t.penup()
t.goto(260, 20)
t.pendown()
t.goto(280,20)
t.penup()
t.goto(260,35)
t.pendown()
t.goto(280,35)
t.penup()
t.goto(260,50)
t.pendown()
t.goto(280,50)
t.penup()
t.goto(260,65)
t.pendown()
t.goto(280,65)
t.penup()
t.goto(260,80)
t.pendown()
t.goto(280,80)
t.penup()
t.goto(260,95)
t.pendown()
t.goto(280,95)
#SEMAFORO 1
#CAJA
a.penup()
a.goto(115, -300)
a.pendown()
a.fillcolor("gray66")
a.begin_fill()
a.forward(40)
a.left(90)
a.forward(84)
a.left(90)
a.forward(40)
a.left(90)
a.forward(84)
a.end_fill()
#BASE
a.fillcolor("black")
a.begin_fill()
a.left(90)
a.fd(15)
a.right(90)
a.fd(20)
a.left(90)
a.fd(10)
a.left(90)
a.fd(20)
a.left(90)
a.fd(10)
a.end_fill()
a.penup()
a.goto(144,-320)
a.pendown()
a.fillcolor("black")
a.begin_fill()
a.right(90)
a.circle(8.8,180,15)
a.left(90)
a.fd(17.6)
a.end_fill()
a.penup()
#LUCES
a.penup()
a.goto(135,-290)
a.pendown()
a.fillcolor("red4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.left(90)
a.penup()
a.fd(22)
a.right(90)
a.pendown()
a.fillcolor("yellow4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.left(90)
a.penup()
a.fd(22)
a.right(90)
a.pendown()
a.fillcolor("green4")
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
#SEMAFORO 2
#CAJA
b.penup()
b.goto(320, 110)
b.pendown()
b.left(180)
b.fillcolor("gray66")
b.begin_fill()
b.fd(84)
b.right(90)
b.fd(40)
b.right(90)
b.fd(84)
b.right(90)
b.fd(40)
b.end_fill()
#BASE
b.left(180)
b.fd(15)
b.fillcolor("black")
b.begin_fill()
b.right(90)
b.fd(20)
b.left(90)
b.fd(10)
b.left(90)
b.fd(20)
b.end_fill()
b.penup()
b.goto(340,139)
b.pendown()
b.fillcolor("black")
b.begin_fill()
b.circle(8.8,180,15)
b.left(90)
b.fd(17.6)
b.end_fill()
#LUCES
b.penup()
b.goto(265, 130)
b.pendown()
b.fillcolor("green4")
b.begin_fill()
b.circle(10,360,15)
b.right(90)
b.end_fill()
b.penup()
b.fd(2)
b.pendown()
b.fillcolor("yellow4")
b.begin_fill()
b.right(90)
b.circle(10,360,15)
b.left(90)
b.end_fill()
b.penup()
b.fd(22)
b.pendown()
b.fillcolor("red4")
b.begin_fill()
b.right(90)
b.circle(10,360,15)
b.end_fill()
#SEMAFORO 3
#CAJA
c.penup()
c.goto(-115, 300)
c.pendown()
c.fillcolor("gray66")
c.begin_fill()
c.right(90)
c.fd(84)
c.right(90)
c.fd(40)
c.right(90)
c.fd(84)
c.right(90)
c.fd(40)
c.end_fill()
c.left(180)
#BASE
c.fd(15)
c.right(90)
c.fillcolor("black")
c.begin_fill()
c.fd(20)
c.left(90)
c.fd(10)
c.left(90)
c.fd(20)
c.end_fill()
c.penup()
c.goto(-144, 320)
c.pendown()
c.fillcolor("black")
c.begin_fill()
c.circle(8.8,180,15)
c.left(90)
c.fd(17.6)
c.end_fill()
#LUCES
c.penup()
c.goto(-135, 245)
c.pendown()
c.fillcolor("green4")
c.begin_fill()
c.circle(10,360,15)
c.end_fill()
c.right(90)
c.penup()
c.fd(2)
c.right(90)
c.pendown()
c.fillcolor("yellow4")
c.begin_fill()
c.circle(10,360,15)
c.end_fill()
c.penup()
c.left(90)
c.fd(22)
c.pendown()
c.fillcolor("red4")
c.begin_fill()
c.right(90)
c.circle(10,360,15)
c.end_fill()
#SEMAFORO 4
#CAJA
d.penup()
d.goto(-320,-105)
d.pendown()
d.fillcolor("gray66")
d.begin_fill()
d.fd(84)
d.right(90)
d.fd(40)
d.right(90)
d.fd(84)
d.right(90)
d.fd(40)
d.end_fill()
#BASE
d.left(180)
d.fd(15)
d.right(90)
d.fillcolor("black")
d.begin_fill()
d.fd(20)
d.left(90)
d.fd(10)
d.left(90)
d.fd(20)
d.end_fill()
d.penup()
d.goto(-340,-134)
d.pendown()
d.fillcolor("black")
d.begin_fill()
d.circle(8.8,180,15)
d.left(90)
d.fd(17.6)
d.end_fill()
#LUCES
d.penup()
d.goto(-265,-125)
d.pendown()
d.fillcolor("green4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
d.right(90)
d.penup()
d.fd(2)
d.pendown()
d.right(90)
d.fillcolor("yellow4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
d.penup()
d.left(90)
d.fd(22)
d.pendown()
d.right(90)
d.fillcolor("red4")
d.begin_fill()
d.circle(10,360,15)
d.end_fill()
h0=[0, 8]
h05=[0,9]
h1=[1, 9]
h2=[2,10]
h3=[3,11]
h4=[4,12]
h5=[5,13]
h6=[6,14]
h7=[7,16]
#SEM1
l0.hideturtle()
l0.home()
l0.color("purple")
l0.shapesize(2,2,2)
l0.shape("turtle")
l0.speed(0.5)
l0.penup()
l0.goto(55,-300)
l0.left(90)
l0.showturtle()
l1.hideturtle()
l1.home()
l1.color("red")
l1.shapesize(2,2,2)
l1.shape("turtle")
l1.speed(0.5)
l1.penup()
l1.goto(55,-350)
l1.left(90)
l1.showturtle()
#SEM2
l2.hideturtle()
l2.home()
l2.color("red")
l2.shapesize(2,2,2)
l2.shape("turtle")
l2.speed(0.5)
l2.penup()
l2.goto(-320,-55)
l2.showturtle()
l3.hideturtle()
l3.home()
l3.color("red")
l3.shapesize(2,2,2)
l3.shape("turtle")
l3.speed(0.5)
l3.penup()
l3.goto(-380,-55)
l3.showturtle()
l4.hideturtle()
l4.home()
l4.color("red")
l4.shapesize(2,2,2)
l4.shape("turtle")
l4.speed(0.5)
l4.penup()
l4.goto(-440,-55)
l4.showturtle()
#SEM3
l5.hideturtle()
l5.home()
l5.color("red")
l5.shapesize(2,2,2)
l5.shape("turtle")
l5.speed(0.5)
l5.penup()
l5.goto(-55,300)
l5.right(90)
l5.showturtle()
l6.hideturtle()
l6.home()
l6.color("red")
l6.shapesize(2,2,2)
l6.shape("turtle")
l6.speed(0.5)
l6.penup()
l6.goto(-55,350)
l6.right(90)
l6.showturtle()
#SEM4
l7.hideturtle()
l7.home()
l7.color("red")
l7.shapesize(2,2,2)
l7.shape("turtle")
l7.speed(0.5)
l7.penup()
l7.left(180)
l7.goto(320,55)
l7.showturtle()
l8.hideturtle()
l8.home()
l8.color("red")
l8.shapesize(2,2,2)
l8.shape("turtle")
l8.speed(0.5)
l8.penup()
l8.left(180)
l8.goto(380,55)
l8.showturtle()
l9.hideturtle()
l9.home()
l9.color("red")
l9.shapesize(2,2,2)
l9.shape("turtle")
l9.speed(0.5)
l9.penup()
l9.left(180)
l9.goto(440,55)
l9.showturtle()
l10.hideturtle()
l10.home()
l10.color("red")
l10.shapesize(2,2,2)
l10.shape("turtle")
l10.speed(0.5)
l10.penup()
l10.left(180)
l10.goto(500,55)
l10.showturtle()
gpio.setmode(gpio.BOARD)
gpio.setup(3, gpio.OUT)
gpio.setup(5, gpio.OUT)
gpio.setup(7, gpio.OUT)
gpio.setup(11, gpio.OUT)
gpio.setup(13, gpio.OUT)
gpio.setup(15, gpio.OUT)
gpio.setup(19, gpio.OUT)
gpio.setup(21, gpio.OUT)
gpio.setup(23, gpio.OUT)
gpio.setup(29, gpio.OUT)
gpio.setup(31, gpio.OUT)
gpio.setup(33, gpio.OUT)
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.LOW)
time.sleep(2)
while (x<16):
if x in h0:
time.sleep(1)
v1="green2"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red4"
r2="red"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.HIGH)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l7.hideturtle()
l7.speed(0.5)
l7.home()
l7.color("red")
l7.shapesize(2,2,2)
l7.shape("turtle")
l7.speed(0.5)
l7.penup()
l7.left(180)
l7.goto(320,55)
l7.showturtle()
l8.hideturtle()
l8.speed(0.5)
l8.home()
l8.color("red")
l8.shapesize(2,2,2)
l8.shape("turtle")
l8.penup()
l8.left(180)
l8.goto(380,55)
l8.showturtle()
l9.hideturtle()
l9.speed(0.5)
l9.home()
l9.color("red")
l9.shapesize(2,2,2)
l9.shape("turtle")
l9.penup()
l9.left(180)
l9.goto(440,55)
l9.showturtle()
l10.hideturtle()
l10.speed(0.5)
l10.home()
l10.color("red")
l10.shapesize(2,2,2)
l10.shape("turtle")
l10.penup()
l10.left(180)
l10.goto(500,55)
l10.showturtle()
if x==8:
x=x+1
#x=x+1
elif x in h1:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red4"
r2="red"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.HIGH)
gpio.output(7, gpio.LOW)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
x=x+1
elif x in h2:
time.sleep(1)
v1="green4"
v2="green2"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red4"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.HIGH)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l0.hideturtle()
l0.speed(0.5)
l0.home()
l0.color("purple")
l0.shapesize(2,2,2)
l0.shape("turtle")
l0.penup()
l0.goto(55,-300)
l0.left(90)
l0.showturtle()
l1.hideturtle()
l1.speed(0.5)
l1.home()
l1.color("red")
l1.shapesize(2,2,2)
l1.shape("turtle")
l1.penup()
l1.goto(55,-350)
l1.left(90)
l1.showturtle()
x=x+1
elif x in h3:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red4"
r3="red"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.HIGH)
gpio.output(15, gpio.LOW)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(23, gpio.HIGH)
x=x+1
elif x in h4:
time.sleep(1)
v1="green4"
v2="green4"
v3="green2"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red"
r3="red4"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.HIGH)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
l2.hideturtle()
l2.speed(0.5)
l2.home()
l2.color("red")
l2.shapesize(2,2,2)
l2.shape("turtle")
l2.penup()
l2.goto(-320,-55)
l2.showturtle()
l3.hideturtle()
l3.speed(0.5)
l3.home()
l3.color("red")
l3.shapesize(2,2,2)
l3.shape("turtle")
l3.penup()
l3.goto(-380,-55)
l3.showturtle()
l4.hideturtle()
l4.speed(0.5)
l4.home()
l4.color("red")
l4.shapesize(2,2,2)
l4.shape("turtle")
l4.penup()
l4.goto(-440,-55)
l4.showturtle()
x=x+1
elif x in h5:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow"
a4="yellow4"
r1="red"
r2="red"
r3="red4"
r4="red"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.HIGH)
gpio.output(23, gpio.LOW)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.HIGH)
x=x+1
elif x in h6:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green2"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow4"
r1="red"
r2="red"
r3="red"
r4="red4"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.HIGH)
gpio.output(31, gpio.LOW)
gpio.output(33, gpio.LOW)
l5.hideturtle()
l5.home()
l5.speed(0.5)
l5.color("red")
l5.shapesize(2,2,2)
l5.shape("turtle")
l5.penup()
l5.goto(-55,300)
l5.right(90)
l5.showturtle()
l6.hideturtle()
l6.speed(0.5)
l6.home()
l6.color("red")
l6.shapesize(2,2,2)
l6.shape("turtle")
l6.penup()
l6.goto(-55,350)
l6.right(90)
l6.showturtle()
if x == 14:
break
x=x+1
elif x in h7:
time.sleep(1)
v1="green4"
v2="green4"
v3="green4"
v4="green4"
a1="yellow4"
a2="yellow4"
a3="yellow4"
a4="yellow"
r1="red"
r2="red"
r3="red"
r4="red4"
#PRIMER SEMAFORO
gpio.output(3, gpio.LOW)
gpio.output(5, gpio.LOW)
gpio.output(7, gpio.HIGH)
#SEGUNDO SEMAFORO
gpio.output(11, gpio.LOW)
gpio.output(13, gpio.LOW)
gpio.output(15, gpio.HIGH)
#TERCER SEMAFORO
gpio.output(19, gpio.LOW)
gpio.output(21, gpio.LOW)
gpio.output(23, gpio.HIGH)
#CUARTO SEMAFORO
gpio.output(29, gpio.LOW)
gpio.output(31, gpio.HIGH)
gpio.output(33, gpio.LOW)
x=x+1
a.penup()
a.goto(135,-246)
a.pendown()
a.fillcolor(v1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.penup()
a.goto(135,-268)
a.pendown()
a.fillcolor(a1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
a.penup()
a.goto(135,-290)
a.pendown()
a.fillcolor(r1)
a.begin_fill()
a.circle(10,360,25)
a.end_fill()
d.penup()
d.home()
d.goto(-255,-115)
d.fillcolor(v2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
d.penup()
d.home()
d.goto(-277,-115)
d.fillcolor(a2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
d.penup()
d.home()
d.goto(-299,-115)
d.fillcolor(r2)
d.begin_fill()
d.pendown()
d.left(180)
d.circle(10,360,25)
d.end_fill()
c.penup()
c.home()
c.goto(-135, 245)
c.pendown()
c.fillcolor(v3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
c.penup()
c.home()
c.goto(-135, 267)
c.pendown()
c.fillcolor(a3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
c.penup()
c.home()
c.goto(-135, 289)
c.pendown()
c.fillcolor(r3)
c.begin_fill()
c.left(180)
c.circle(10,360,15)
c.end_fill()
b.penup()
b.home()
b.goto(255, 140)
b.pendown()
b.fillcolor(v4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
b.penup()
b.home()
b.goto(277, 140)
b.pendown()
b.fillcolor(a4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
b.penup()
b.home()
b.goto(299, 140)
b.pendown()
b.fillcolor(r4)
b.begin_fill()
b.left(180)
b.circle(10,360,15)
b.end_fill()
if x in h7:
l7.speed(2)
l8.speed(2)
l9.speed(2)
l10.speed(2)
l7.fd(90)
l8.fd(90)
l9.fd(90)
l10.fd(90)
l7.right(90)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.fd(100)
l7.circle(150,90,10)
l7.right(90)
l8.fd(60)
l9.fd(60)
l10.fd(60)
l7.fd(500)
l8.right(90)
l8.circle(150,90,10)
l8.fd(100)
l8.circle(150,80,10)
l8.fd(100)
l8.circle(150,90,10)
l8.right(80)
l9.fd(60)
l10.fd(60)
l8.fd(200)
l9.right(90)
l9.circle(150,90,10)
l9.fd(100)
l9.circle(150,90,10)
l9.right(90)
l10.fd(60)
l10.right(80)
l10.circle(150,80,10)
l10.right(90)
l9.fd(600)
l10.fd(200)
#x=x+1
if x in h5:
l5.speed(2)
l6.speed(2)
l5.fd(90)
l6.fd(90)
l5.right(90)
l5.circle(150,90,10)
l5.right(90)
l5.fd(600)
l6.fd(60)
l6.right(90)
l6.circle(150,90,10)
l6.right(90)
l6.fd(600)
#x=x+1
if x in h3:
l2.speed(2)
l3.speed(2)
l4.speed(2)
l2.fd(90)
l3.fd(90)
l4.fd(90)
l2.right(90)
l2.circle(150,90,10)
l2.fd(100)
l2.circle(150,90,10)
l2.fd(100)
l2.circle(150,80,10)
l2.right(80)
l3.fd(60)
l4.fd(60)
l3.right(90)
l3.circle(150,90,10)
l3.fd(100)
l3.circle(150,90,10)
l3.right(90)
l4.fd(60)
l4.right(90)
l4.circle(150,90,10)
l4.right(90)
l2.fd(200)
l3.fd(600)
l4.fd(200)
#x=x+1
if x in h05:
l0.speed(2)
l1.speed(2)
l0.fd(120)
l1.fd(80)
l0.right(90)
l0.circle(150,80,10)
l0.right(80)
l0.fd(500)
l1.fd(50)
l1.right(90)
l1.circle(150,90,10)
l1.fd(100)
l1.circle(150,90,10)
l1.right(90)
l1.fd(200)
x=x+1

Comentarios
Publicar un comentario