Skip to content
Snippets Groups Projects
Commit 4b6d5da4 authored by Vincent Namy (EDU_GE)'s avatar Vincent Namy (EDU_GE)
Browse files

[Télécommande] Ajout code télécommande + dessin pc

parent 0c6bb6ea
Branches
No related tags found
No related merge requests found
'''
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])
'''
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])
'''
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))
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment