Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCHW_WIndows_Final #115

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/modules/TrainControllerHW_WIN64/TestEnv/GPIO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from gpiozero import LED
#imports LED functions from gpiozero library
from gpiozero import Button
#imports Button functions from gpiozero library

led = LED(4)
#declare the GPIO pin 4 for LED output and store it in led variable
button = Button(17)
#declare the GPIO pin 17 for Button output and store it in button variable

while True:
#initiated an infinite while loop
button.wait_for_press()
#use the built-in function of the button to wait till press
led.on()
#turn on the led
button.wait_for_release()
#use the built-in function of button to wait till release
led.off()
#turn off the led
13 changes: 13 additions & 0 deletions src/modules/TrainControllerHW_WIN64/TestEnv/PSv2_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import paho.mqtt.client as mqtt
broker = "broker.hivemq.com"
port = 8000

def on_publish(client,userdata,result): #create function for callback
print("data published \n")
pass


client1= mqtt.Client("control1") #create client object
client1.on_publish = on_publish #assign function to callback
client1.connect(broker,port) #establish connection
ret = client1.publish("trains/vitals","bf1") #publish
Loading
Loading