diff --git a/Telecommande/main_pc.py b/Telecommande/main_pc.py new file mode 100644 index 0000000000000000000000000000000000000000..bf496a114b459de7b08287e17921098cef184490 --- /dev/null +++ b/Telecommande/main_pc.py @@ -0,0 +1,25 @@ +''' +Gestion télécommande Pour Micro:bit OC Robotique 2025 +Auteur·ice : Vincent Namy +Version : 1.0 +Date : 3.2.25 + +''' +from microbit import * +from protocole import * +display.off() + +if __name__ == '__main__': + + userId = 1 + destId = 0 + + # Main + while True: + sleep(10) + m = receive_msg(userId) + if m and m.msgId==73: + print("x", m.payload[0]*4, "y", m.payload[1]*4, "z", m.payload[2]) + + + diff --git a/Telecommande/main_robot.py b/Telecommande/main_robot.py new file mode 100644 index 0000000000000000000000000000000000000000..bf496a114b459de7b08287e17921098cef184490 --- /dev/null +++ b/Telecommande/main_robot.py @@ -0,0 +1,25 @@ +''' +Gestion télécommande Pour Micro:bit OC Robotique 2025 +Auteur·ice : Vincent Namy +Version : 1.0 +Date : 3.2.25 + +''' +from microbit import * +from protocole import * +display.off() + +if __name__ == '__main__': + + userId = 1 + destId = 0 + + # Main + while True: + sleep(10) + m = receive_msg(userId) + if m and m.msgId==73: + print("x", m.payload[0]*4, "y", m.payload[1]*4, "z", m.payload[2]) + + + diff --git a/Telecommande/main_telecommande.py b/Telecommande/main_telecommande.py new file mode 100644 index 0000000000000000000000000000000000000000..11b9b4e088a8cf2b6e9473ed4232515cda6a0c01 --- /dev/null +++ b/Telecommande/main_telecommande.py @@ -0,0 +1,26 @@ +''' +Gestion télécommande Pour Micro:bit OC Robotique 2025 +Auteur·ice : Vincent Namy +Version : 1.0 +Date : 3.2.25 + +''' +from microbit import * +from protocole import * +display.off() + +if __name__ == '__main__': + + userId = 0 + destId = 1 + + # Main + while True: + sleep(10) + print("x", pin4.read_analog()//4, "y", pin3.read_analog()//4, "z", pin5.read_digital()) + + payload = [pin4.read_analog()//4, pin3.read_analog()//4, pin5.read_digital()] + print("sent : ", send_msg(73,payload,userId, destId)) + + + diff --git a/Telecommande/pc.py b/Telecommande/pc.py new file mode 100644 index 0000000000000000000000000000000000000000..5aefb397ac1a3403e732cc878ff2140eae049937 --- /dev/null +++ b/Telecommande/pc.py @@ -0,0 +1,37 @@ +import serial +from turtle import * + +# Configuration du port série +port = "/dev/ttyACM1" +baudrate = 115200 +bytesize = serial.EIGHTBITS +parity = serial.PARITY_NONE +stopbits = serial.STOPBITS_ONE +timeout = 1 + +# Ouverture du port série +ser = serial.Serial(port, baudrate, bytesize, parity, stopbits, timeout) +penup() +lastZ = 0 +ecrire = False +while True: + # Lecture des données disponibles sur le port série + line = ser.readline().decode() + + # Affichage des données reçues + if line and len(line)>1: + s = line.split() + if len(s)>5: + x= int(s[1])-(512+16) + y= int(s[3])-(512-4) + z = int(s[5]) + print(x, y) + if z and not lastZ: + ecrire = not ecrire + if ecrire : + pendown() + else: + penup() + goto(xcor()+x//10, ycor()+y//10) + lastZ = z + \ No newline at end of file