mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Lecteur série Arduino et Micro:bit
This commit is contained in:
parent
2eca28aa35
commit
73ea064622
BIN
ropy-29.blend
BIN
ropy-29.blend
Binary file not shown.
35
rp.py
35
rp.py
@ -11,9 +11,9 @@ import webbrowser # Lien internet
|
||||
import threading # Multithreading
|
||||
import xml.etree.ElementTree as ET # Creating/parsing XML file
|
||||
import runpy # Execution de script Python légère (sans import)
|
||||
# import serial # Liaison série (jumeau numérique)
|
||||
import serial # Liaison série (jumeau numérique)
|
||||
|
||||
import rp_map1 as rp_map # Map definition
|
||||
import rp_map1 as rp_map # Map definition
|
||||
import rp_doc # Documentation
|
||||
import rp_store # Store
|
||||
import rp_about # About
|
||||
@ -126,15 +126,6 @@ def points_maj (cont):
|
||||
obj=scene.objects['Rover']
|
||||
obj['w_position']=str(round(obj.worldPosition.x,3))+","+str(round(obj.worldPosition.y,3))+","+str(round(obj.worldPosition.z,3))
|
||||
|
||||
# Jumeau numérique
|
||||
# if scene.objects['Commands']['twins'] and scene.objects['Points-Twins'].visible == False:
|
||||
# scene.objects['Points-Twins'].setVisible(True,True)
|
||||
# scene.objects['Points-Twins-text'].setVisible(True,False)
|
||||
|
||||
# scene.objects['Commands']['twins_port'] = port
|
||||
# scene.objects['Commands']['twins_speed'] = speed
|
||||
# scene.objects['Commands']['twins'] = True
|
||||
|
||||
###############################################################################
|
||||
# Terrain
|
||||
###############################################################################
|
||||
@ -347,6 +338,16 @@ def terrain_grid_anim ():
|
||||
if scene.objects['Grid-u']['timer']>= 1:
|
||||
scene.objects['Grid-u']['anim'] = False
|
||||
|
||||
###############################################################################
|
||||
# Jumeau
|
||||
###############################################################################
|
||||
|
||||
def twins_listen():
|
||||
print ("a")
|
||||
serial_tmp= serial.Serial(scene.objects['Commands']['twins_port'],scene.objects['Commands']['twins_speed'])
|
||||
serial_msg = str(serial_tmp.readline())
|
||||
print (serial_msg)
|
||||
|
||||
###############################################################################
|
||||
# Sons
|
||||
###############################################################################
|
||||
@ -1029,9 +1030,9 @@ def tablet_close ():
|
||||
|
||||
# Overlay
|
||||
scene.objects['Points'].setVisible(True,True)
|
||||
if scene.objects['Commands']['twins'] ==False:
|
||||
scene.objects['Points-Twins'].setVisible(False,True)
|
||||
scene.objects['Points-Twins-text'].setVisible(False,False)
|
||||
if scene.objects['Commands']['twins']:
|
||||
scene.objects['Points-Twins'].setVisible(True,True)
|
||||
scene.objects['Points-Twins-text'].setVisible(True,False)
|
||||
scene.objects['Commands'].setVisible(True,True)
|
||||
scene.objects['Camera'].setVisible(True,True)
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
@ -1273,9 +1274,9 @@ def store_close():
|
||||
|
||||
# Overlay
|
||||
scene.objects['Points'].setVisible(True,True)
|
||||
if scene.objects['Commands']['twins'] ==False:
|
||||
scene.objects['Points-Twins'].setVisible(False,True)
|
||||
scene.objects['Points-Twins-text'].setVisible(False,False)
|
||||
if scene.objects['Commands']['twins']:
|
||||
scene.objects['Points-Twins'].setVisible(True,True)
|
||||
scene.objects['Points-Twins-text'].setVisible(True,False)
|
||||
scene.objects['Commands'].setVisible(True,True)
|
||||
scene.objects['Camera'].setVisible(True,True)
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
|
48
rp_cmd.py
48
rp_cmd.py
@ -22,6 +22,10 @@ from rp_lib import * # Bibliothèque Ropy
|
||||
# Fonctions
|
||||
###############################################################################
|
||||
|
||||
def mrp_avancer():
|
||||
rp_avancer()
|
||||
rp_marquer()
|
||||
|
||||
###############################################################################
|
||||
# Commandes
|
||||
###############################################################################
|
||||
@ -29,17 +33,43 @@ from rp_lib import * # Bibliothèque Ropy
|
||||
def commandes():
|
||||
|
||||
# Ecrire votre code ici ...
|
||||
rp_jumeau('/dev/ttyACM0', 115200)
|
||||
rp_jumeau_config(50, 20, 90) # (vitesse, temps_avancer, temps_rotation)
|
||||
rp_jumeau('/dev/ttyACM1', 115200)
|
||||
rp_tempo(1)
|
||||
print (1)
|
||||
rp_tempo(1)
|
||||
print (2)
|
||||
rp_tempo(1)
|
||||
print (3)
|
||||
rp_tempo(1)
|
||||
print (4)
|
||||
|
||||
rp_gauche()
|
||||
# rp_marquer()
|
||||
rp_avancer()
|
||||
# rp_marquer()
|
||||
# rp_avancer()
|
||||
# rp_marquer()
|
||||
|
||||
|
||||
# rp_serie_msg("Go !")
|
||||
# txt =""
|
||||
# while True:
|
||||
# rp_tempo(0.1)
|
||||
# pass
|
||||
# txt=rp_serie_rcpt()
|
||||
# print (txt)
|
||||
# if txt !="":
|
||||
# print (txt)
|
||||
# break
|
||||
|
||||
# rp_jumeau_config(50, 20, 90) # (vitesse, temps_avancer, temps_rotation)
|
||||
# rp_tempo(1)
|
||||
|
||||
# rp_gauche()
|
||||
# mrp_avancer()
|
||||
# rp_droite()
|
||||
# mrp_avancer()
|
||||
# mrp_avancer()
|
||||
# mrp_avancer()
|
||||
# mrp_avancer()
|
||||
# rp_droite()
|
||||
# mrp_avancer()
|
||||
# mrp_avancer()
|
||||
|
||||
rp_jumeau_close()
|
||||
rp_fin() # A garder
|
||||
|
||||
###############################################################################
|
||||
|
@ -3,9 +3,9 @@
|
||||
<speed>1.0</speed>
|
||||
<sound>False</sound>
|
||||
<cam>
|
||||
<worldPosition.x>0.0057830810546875</worldPosition.x>
|
||||
<worldPosition.y>-26.440298080444336</worldPosition.y>
|
||||
<worldPosition.z>20.22315788269043</worldPosition.z>
|
||||
<worldPosition.x>-10.94022274017334</worldPosition.x>
|
||||
<worldPosition.y>-40.040931701660156</worldPosition.y>
|
||||
<worldPosition.z>30.490596771240234</worldPosition.z>
|
||||
</cam>
|
||||
<screen>
|
||||
<width>1280</width>
|
||||
@ -14,12 +14,12 @@
|
||||
</config>
|
||||
<mission>
|
||||
<current>1</current>
|
||||
<level>1</level>
|
||||
<level>2</level>
|
||||
</mission>
|
||||
<upgrade>
|
||||
<battery>False</battery>
|
||||
<beacon>False</beacon>
|
||||
<paint>False</paint>
|
||||
<speed>False</speed>
|
||||
<speed>True</speed>
|
||||
</upgrade>
|
||||
</data>
|
24
rp_lib.py
24
rp_lib.py
@ -219,6 +219,7 @@ def rp_avancer ():
|
||||
|
||||
# Animation rapide
|
||||
if scene.objects['Commands']['speed'] >= 10 and scene.objects['Points']['step']> 2: # A tendance à planter sur les premiers mouvements en rapide + balisage
|
||||
rp_tempo (0.1)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
z0 = obj.worldPosition.z
|
||||
@ -250,7 +251,7 @@ def rp_avancer ():
|
||||
# rp_tempo (0.1*step)
|
||||
|
||||
# Animation
|
||||
if scene.objects['Commands']['speed'] < 10:
|
||||
if scene.objects['Commands']['speed'] < 10 or scene.objects['Points']['step']<=2:
|
||||
start = 1
|
||||
end = 100
|
||||
layer = 0
|
||||
@ -340,6 +341,7 @@ def rp_reculer ():
|
||||
|
||||
# Animation rapide
|
||||
if scene.objects['Commands']['speed'] >= 10 and scene.objects['Points']['step']> 2: # A tendance à planter sur les premiers mouvements en rapide + balisage
|
||||
rp_tempo (0.1)
|
||||
x0 = obj.worldPosition.x
|
||||
y0 = obj.worldPosition.y
|
||||
z0 = obj.worldPosition.z
|
||||
@ -409,6 +411,7 @@ def rp_gauche ():
|
||||
|
||||
# Animation rapide
|
||||
if scene.objects['Commands']['speed'] >= 10:
|
||||
rp_tempo (0.1)
|
||||
obj.applyRotation((0, 0, step), True)
|
||||
rp_tempo (0.1)
|
||||
return True
|
||||
@ -458,6 +461,7 @@ def rp_droite ():
|
||||
|
||||
# Rapide
|
||||
if scene.objects['Commands']['speed'] >= 10:
|
||||
rp_tempo (0.1)
|
||||
obj.applyRotation((0, 0, -step), True)
|
||||
rp_tempo (0.1)
|
||||
return True
|
||||
@ -896,6 +900,11 @@ def rover_goal ():
|
||||
print ("Goal !!")
|
||||
obj['stop'] = True
|
||||
|
||||
# Jumeau numérique
|
||||
if scene.objects['Commands']['twins']:
|
||||
serial_msg = "OB\n"
|
||||
twins_serial.write(serial_msg.encode()) # Communication série : modele 3d -> carte communication ( arduino | micro:bit )
|
||||
|
||||
# Animation
|
||||
start = 1
|
||||
end = 160
|
||||
@ -1165,10 +1174,17 @@ def rp_serie_msg(text):
|
||||
global twins_serial
|
||||
twins_serial.write(text.encode())
|
||||
|
||||
def rp_serie_rcpt():
|
||||
def twins_listen():
|
||||
global twins_serial
|
||||
print ("Not yet implemented") # FIXME
|
||||
return ("Not yet implemented")
|
||||
print ("a")
|
||||
serial_msg = str(twins_serial.readline())
|
||||
print (serial_msg)
|
||||
|
||||
def rp_serie_rcpt():
|
||||
pass
|
||||
# global twins_serial
|
||||
# print (twins_serial.readline())
|
||||
# return str(twins_serial.readline()) # Communication série : arduino|micro:bit -> modele 3d
|
||||
|
||||
###############################################################################
|
||||
# Fonction bas niveau
|
||||
|
103
twins/arduino-serialreader/arduino-serialreader.ino
Executable file
103
twins/arduino-serialreader/arduino-serialreader.ino
Executable file
@ -0,0 +1,103 @@
|
||||
/******************************************************************************
|
||||
* arduino-serialreader.ino
|
||||
* @title: Lecteur du port serie d'une carte arduino
|
||||
* @project: Ropy (Blender-EduTech)
|
||||
* @lang: fr
|
||||
* @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
* @copyright: Copyright (C) 2022 Philippe Roy
|
||||
* @license: GNU GPL
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Pupitre
|
||||
******************************************************************************/
|
||||
|
||||
// Adressage Led Arduino
|
||||
/* const int led = 13; // Led de mouvement (onboard) */
|
||||
/* const int led_com = 10; // Led de communication modele 3d-> arduino */
|
||||
const int bt = 2; // Bouton
|
||||
const int v = 3; // Voyant
|
||||
|
||||
/******************************************************************************
|
||||
* Communication serie
|
||||
******************************************************************************/
|
||||
|
||||
String serial_msg = ""; // Message
|
||||
bool serial_msg_complet = false; // Flag de message complet
|
||||
|
||||
/******************************************************************************
|
||||
* Initialisation
|
||||
******************************************************************************/
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(bt, INPUT); // Bouton
|
||||
pinMode(v, OUTPUT); // Voyant
|
||||
/* pinMode(led, OUTPUT); // Led de mouvement */
|
||||
/* pinMode(led_com, OUTPUT); // Led de communication modele 3d-> arduino */
|
||||
digitalWrite(v, LOW);
|
||||
/* digitalWrite(led, LOW); */
|
||||
/* digitalWrite(led_com, LOW); */
|
||||
|
||||
Serial.begin(115200); // Moniteur serie
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Boucle principale
|
||||
******************************************************************************/
|
||||
|
||||
void loop() {
|
||||
|
||||
/*****
|
||||
* Communication : modele 3d -> arduino
|
||||
*****/
|
||||
|
||||
if (serial_msg_complet) {
|
||||
|
||||
if (serial_msg =="S\n") bt_num=true; // S pour Set
|
||||
if (serial_msg =="R\n") bt_num=false; // R pour Reset
|
||||
|
||||
Serial.println("Echo : "+serial_msg);
|
||||
serial_msg = "";
|
||||
serial_msg_complet = false;
|
||||
}
|
||||
|
||||
/*****
|
||||
* Bouton (arduino -> modele 3d)
|
||||
*
|
||||
* Bouton physique : LOW = actif et HIGH = pas actif
|
||||
*****/
|
||||
|
||||
if digitalRead(bt) == LOW {
|
||||
Serial.println("B");
|
||||
}
|
||||
|
||||
/*****
|
||||
* Yoyant modele 3d-> arduino
|
||||
*
|
||||
* Bouton numérique (modele 3d) : true = actif et false = pas actif
|
||||
*****/
|
||||
|
||||
if bt_num == true {
|
||||
digitalWrite(v, HIGH);
|
||||
}
|
||||
if bt_num == false {
|
||||
digitalWrite(v, LOW);
|
||||
}
|
||||
|
||||
/* delay(300); */
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Evenements provoques par la communication serie
|
||||
******************************************************************************/
|
||||
|
||||
void serialEvent() {
|
||||
while (Serial.available()) {
|
||||
char inChar = (char)Serial.read();
|
||||
serial_msg += inChar;
|
||||
if (inChar == '\n') {
|
||||
serial_msg_complet = true;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ from microbit import uart, sleep
|
||||
from microbit import *
|
||||
|
||||
###############################################################################
|
||||
# microbit-lecteur_portserie.py
|
||||
# microbit-serialreader.py
|
||||
# @title: Lecteur du port serie d'une carte micro:bit
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
###############################################################################
|
||||
@ -12,9 +12,18 @@ uart.init(baudrate= 115200) # Initialisation du port série
|
||||
while True:
|
||||
|
||||
while not uart.any(): # Attente d'un message
|
||||
pass
|
||||
|
||||
display.scroll('ok : ') # Réception d'un message
|
||||
|
||||
# Envoi d'un message
|
||||
if button_a.is_pressed() :
|
||||
display.scroll("-> A")
|
||||
uart.write("A")
|
||||
if button_b.is_pressed() :
|
||||
display.scroll("-> B")
|
||||
uart.write("B")
|
||||
# pass
|
||||
|
||||
# Réception d'un message
|
||||
display.scroll('<- ')
|
||||
msg = uart.readline()
|
||||
display.scroll(msg[:-1]) # Affichage du message sans le '/n'
|
||||
display.scroll(str(msg[0])+" "+str(msg[1])) # Affichage du message en code ASCII
|
@ -4,7 +4,7 @@ import radio
|
||||
|
||||
###############################################################################
|
||||
# rp_twins_maqueen-relay.py
|
||||
# @title: Jumeau Maqueen : Programme de la carte microbit du relai
|
||||
# @title: Jumeau Maqueen : Programme de la carte microbit du relais
|
||||
# @project: Ropy (Blender-EduTech)
|
||||
# @lang: fr
|
||||
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
|
||||
@ -18,7 +18,7 @@ import radio
|
||||
|
||||
attente_image = Image("00000:00000:00300:00000:00000")
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
balise_image = Image("00300:03630:36963:03630:00300")
|
||||
balise_image = Image("33333:36663:36963:36663:33333")
|
||||
radio.config(group=1, queue=4, length=8)
|
||||
radio.on()
|
||||
|
||||
@ -28,61 +28,72 @@ uart.init(baudrate= 115200) # Initialisation du port série
|
||||
# Écoute du port série en relayage vers la radio
|
||||
###############################################################################
|
||||
|
||||
temps_avancer=20
|
||||
temps_tourner=20
|
||||
temps_marquer=20
|
||||
temps_forer=40
|
||||
temps_colision=40
|
||||
temps_avancer=10
|
||||
temps_tourner=10
|
||||
temps_marquer=100
|
||||
temps_objectif=100
|
||||
temps_forer=100
|
||||
temps_colision=100
|
||||
|
||||
while True:
|
||||
|
||||
|
||||
while not uart.any(): # Attente d'un message
|
||||
pass
|
||||
|
||||
if button_a.is_pressed() or button_b.is_pressed(): # A propos
|
||||
display.scroll ("Ropy : Relais")
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
# pass
|
||||
|
||||
display.show(' ') # Sinon bug ?
|
||||
msg = uart.readline()
|
||||
|
||||
|
||||
# Avancer : AV
|
||||
if msg[0] ==65 and msg[1] ==86 : # Code ASCII : 65 (A) puis 86 (V)
|
||||
display.show(Image.ARROW_N)
|
||||
radio.send("AV")
|
||||
sleep(temps_avancer)
|
||||
radio.send("ST")
|
||||
|
||||
# Reculer : RE
|
||||
if msg[0] ==82 and msg[1] ==69 : # Code ASCII : 82 (R) puis 69 (E)
|
||||
display.show(Image.ARROW_S)
|
||||
radio.send("RE")
|
||||
sleep(temps_avancer)
|
||||
radio.send("ST")
|
||||
|
||||
# Gauche : GA
|
||||
if msg[0] ==71 and msg[1] ==65 : # Code ASCII : 71 (G) puis 65 (A)
|
||||
display.show(Image.ARROW_W)
|
||||
radio.send("GA")
|
||||
sleep(temps_tourner)
|
||||
radio.send("ST")
|
||||
|
||||
# Droite : DR
|
||||
if msg[0] ==68 and msg[1] ==69 : # Code ASCII : 82 (D) puis 82 (R)
|
||||
if msg[0] ==68 and msg[1] ==82 : # Code ASCII : 68 (D) puis 82 (R)
|
||||
display.show(Image.ARROW_E)
|
||||
radio.send("DR")
|
||||
sleep(temps_tourner)
|
||||
radio.send("ST")
|
||||
|
||||
# Marquer : MA
|
||||
if msg[0] ==77 and msg[1] ==65 : # Code ASCII : 77 (M) puis 65 (A)
|
||||
display.show(balise_image)
|
||||
radio.send("MA")
|
||||
sleep(temps_marquer)
|
||||
|
||||
# Objectif atteint : OB
|
||||
if msg[0] ==79 and msg[1] ==66 : # Code ASCII : 79 (O) puis 66 (B)
|
||||
display.show(Image.HAPPY)
|
||||
radio.send("OB")
|
||||
sleep(temps_objectif)
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
|
||||
# Forer : FO
|
||||
if msg[0] ==70 and msg[1] ==79 : # Code ASCII : 70 (F) puis 79 (O)
|
||||
display.show(Image.DIAMOND)
|
||||
radio.send("FO")
|
||||
sleep(temps_forer)
|
||||
|
||||
# Colision : CO
|
||||
if msg[0] ==67 and msg[1] ==79 : # Code ASCII : 67 (C) puis 79 (O)
|
||||
display.show(Image.SKULL)
|
||||
radio.send("CO")
|
||||
sleep(temps_colision)
|
||||
|
||||
# Configuration : CF
|
||||
@ -96,7 +107,7 @@ while True:
|
||||
pass
|
||||
display.show(' ')
|
||||
msg = uart.readline()
|
||||
if msg[0] ==70 and msg[1] ==67 : # Code ASCII : 70 (F) puis 67 (C) -> sortie de la configuration
|
||||
if msg[0] ==70 and msg[1] ==67 : # Code ASCII : 70 (F) puis 67 (C) -> fin de la configuration
|
||||
break
|
||||
# display.scroll (msg[:-1])
|
||||
radio.send(str(msg[:-1]))
|
||||
@ -105,6 +116,7 @@ while True:
|
||||
|
||||
# Fin : FI
|
||||
if msg[0] ==70 and msg[1] ==73 : # Code ASCII : 70 (F) puis 73 (I)
|
||||
radio.send("FI")
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
|
||||
sleep(400)
|
||||
|
@ -19,14 +19,19 @@ import time
|
||||
# Initialisation
|
||||
# ###############################################################################
|
||||
|
||||
# Image
|
||||
attente_image = Image("00000:00000:00900:00000:00000")
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
balise_image = Image("33333:36663:36963:36663:33333")
|
||||
|
||||
# Radio
|
||||
radio.config(group=1, queue=4, length=8)
|
||||
radio.on()
|
||||
|
||||
vitesse = 50
|
||||
distance = 50
|
||||
angle = 90
|
||||
# Paramétrage
|
||||
vitesse = 50 # Vitesse
|
||||
distance = 50 # Distance d'un pas
|
||||
angle = 90 # Angle lors des rotations
|
||||
|
||||
vmax_roue = 85.5 # Vitesse maxi des roues en tr/min
|
||||
diam_roue = 43 # Diamètre des roues en mm
|
||||
@ -38,6 +43,11 @@ dist_essieu = 70 # Distance entre les roues en mm
|
||||
|
||||
while True:
|
||||
|
||||
# A propos
|
||||
if button_a.is_pressed() or button_b.is_pressed():
|
||||
display.scroll ("Ropy : Robot")
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
|
||||
# Lecture de l'ordre
|
||||
ordre=radio.receive()
|
||||
|
||||
@ -81,12 +91,6 @@ while True:
|
||||
pin12.write_digital(0) # Led avant gauche
|
||||
display.clear() # Effacer matrice de leds
|
||||
|
||||
# display.show(Image.ARROW_N)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(1) # Led avant gauche
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, v_avancer])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x0, v_avancer])) # Moteur droit
|
||||
|
||||
# Reculer
|
||||
if ordre=="RE":
|
||||
|
||||
@ -106,12 +110,6 @@ while True:
|
||||
pin12.write_digital(0) # Led avant gauche
|
||||
display.clear() # Effacer matrice de leds
|
||||
|
||||
# display.show(Image.ARROW_S)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(1) # Led avant gauche
|
||||
# i2c.write(0x10, bytearray([0x00, 0x1, v_avancer])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x1, v_avancer])) # Moteur droit
|
||||
|
||||
# Gauche
|
||||
if ordre=="GA":
|
||||
display.show(Image.ARROW_E)
|
||||
@ -129,38 +127,15 @@ while True:
|
||||
pin8.write_digital(0) # Led avant gauche
|
||||
display.clear() # Effacer matrice de leds
|
||||
|
||||
# display.show(Image.ARROW_W)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, 0])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x0, v_tourner])) # Moteur droit
|
||||
|
||||
# Avancer + gauche
|
||||
# if ordre=="AG":
|
||||
# display.show(Image.ARROW_W)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, v_tourner_faible])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x0, v_tourner])) # Moteur droit
|
||||
|
||||
# Reculer + gauche
|
||||
# if ordre=="RG":
|
||||
# display.show(Image.ARROW_W)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x1, v_tourner_faible])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x1, v_tourner])) # Moteur droit
|
||||
|
||||
# Droite
|
||||
if ordre=="DR":
|
||||
|
||||
display.show(Image.ARROW_W)
|
||||
pin12.write_digital(1) # Led avant droit
|
||||
i2c.write(0x10, bytearray([0x00, 0x0, vitesse])) # Avance moteur gauche
|
||||
i2c.write(0x10, bytearray([0x02, 0x1, vitesse])) # Avance moteur droit
|
||||
|
||||
v_roue=(vmax_roue/255)*vitesse
|
||||
v_lin = ((v_roue/60)*2*math.pi)*(diam_roue/2) # Vitesse linéaire
|
||||
v_lin = ((v_roue/60)*2*math.pi)*(diam_roue/2) # Vitesse linéaire
|
||||
angle2=(angle/4)*(2*math.pi/360)
|
||||
time.sleep((dist_essieu*angle2)/v_lin)
|
||||
|
||||
@ -169,35 +144,29 @@ while True:
|
||||
pin12.write_digital(0) # Led avant droit
|
||||
display.clear() # Effacer matrice de leds
|
||||
|
||||
# display.show(Image.ARROW_E)
|
||||
# pin8.write_digital(0) # Led avant gauche
|
||||
# pin12.write_digital(1) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, v_tourner])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x0, 0])) # Moteur droit
|
||||
# Marquer
|
||||
if ordre=="MA":
|
||||
display.show(balise_image)
|
||||
music.play("A7:0")
|
||||
|
||||
# Avancer + droite
|
||||
# if ordre=="AD":
|
||||
# display.show(Image.ARROW_W)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, v_tourner])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x0, v_tourner_faible])) # Moteur droit
|
||||
# Objectif
|
||||
if ordre=="OB":
|
||||
display.show(Image.HAPPY)
|
||||
music.play(music.ENTERTAINER)
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
|
||||
# Reculer + droite
|
||||
# if ordre=="RD":
|
||||
# display.show(Image.ARROW_W)
|
||||
# pin8.write_digital(1) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x1, v_tourner])) # Moteur gauche
|
||||
# i2c.write(0x10, bytearray([0x02, 0x1, v_tourner_faible])) # Moteur droit
|
||||
# Forer
|
||||
if ordre=="FO":
|
||||
display.show(Image.DIAMOND)
|
||||
|
||||
# Stop
|
||||
# if ordre=="ST":
|
||||
# display.show(attente_image) # Témoin de fonctionnement
|
||||
# pin8.write_digital(0) # Led avant gauche
|
||||
# pin12.write_digital(0) # Led avant droit
|
||||
# i2c.write(0x10, bytearray([0x00, 0x0, 0]))
|
||||
# i2c.write(0x10, bytearray([0x02, 0x1, 0]))
|
||||
# Colision : CO
|
||||
if ordre=="CO":
|
||||
display.show(Image.SKULL)
|
||||
music.play(music.FUNERAL)
|
||||
|
||||
# Fin
|
||||
if ordre=="FI":
|
||||
display.show(attente_image) # Témoin de fonctionnement
|
||||
|
||||
# Cadencement
|
||||
# sleep(100)
|
||||
|
Loading…
Reference in New Issue
Block a user