Skip to content

Commit 2f9be9e

Browse files
authored
TCHW_WIndows_Final
lol whoops pt. 2
1 parent 29e8482 commit 2f9be9e

15 files changed

Lines changed: 2390 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from gpiozero import LED
2+
#imports LED functions from gpiozero library
3+
from gpiozero import Button
4+
#imports Button functions from gpiozero library
5+
6+
led = LED(4)
7+
#declare the GPIO pin 4 for LED output and store it in led variable
8+
button = Button(17)
9+
#declare the GPIO pin 17 for Button output and store it in button variable
10+
11+
while True:
12+
#initiated an infinite while loop
13+
button.wait_for_press()
14+
#use the built-in function of the button to wait till press
15+
led.on()
16+
#turn on the led
17+
button.wait_for_release()
18+
#use the built-in function of button to wait till release
19+
led.off()
20+
#turn off the led
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import paho.mqtt.client as mqtt
2+
broker = "broker.hivemq.com"
3+
port = 8000
4+
5+
def on_publish(client,userdata,result): #create function for callback
6+
print("data published \n")
7+
pass
8+
9+
10+
client1= mqtt.Client("control1") #create client object
11+
client1.on_publish = on_publish #assign function to callback
12+
client1.connect(broker,port) #establish connection
13+
ret = client1.publish("trains/vitals","bf1") #publish

0 commit comments

Comments
 (0)