Skip to content
Snippets Groups Projects
Commit c7989441 authored by JeongMin Choi's avatar JeongMin Choi
Browse files

added mode

parent 72a0a381
No related branches found
No related tags found
No related merge requests found
......@@ -5,29 +5,35 @@ import time
import threading
tf = TFmini()
button = Button(15)
button0 = Button(11)
button1 = Button(13)
button2 = Button(15)
tf.open()
def openBluetooth():
os.system("sudo rfcomm watch hci0")
bluetoothThread = threading.Thread(target=openBluetooth)
bluetoothThread.start()
while True:
if os.path.exists("/dev/rfcomm0"):
print("testing")
blue = serialBluetooth()
while True:
if button.isPressed():
try:
if button0.isPressed():
distance = tf.getDistance()
if blue.isOpen() :
blue.write("0,"+str(distance)+",0")
print("0,"+str(distance)+",0")
time.sleep(50);
time.sleep(0.1)
elif button1.isPressed():
distance = tf.getDistance()
if blue.isOpen() :
blue.write("1,"+str(distance)+",0")
print("1,"+str(distance)+",0")
time.sleep(0.1)
elif button2.isPressed():
distance = tf.getDistance()
if blue.isOpen() :
blue.write("2,"+str(distance)+",0")
print("2,"+str(distance)+",0")
time.sleep(2);
except KeyboardInterrupt: # Ctrl+C
tf.close()
bluetoothThread.join()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment