Пример #1
0
from physique import Pyboard

feather = Pyboard("/dev/ttyACM0")

reponse = feather.exec_script("""
print("Hello")
print("MicroPython")
""")

print(reponse)
adc = ADC(Pin('A2'))                           # Activation du CAN sur la broche A0
buf = array.array("h", [0]*nb) # h = signed short (entier sur 2 octets)
tim = Timer(6, freq=f)                         # Paramétrage du timer du CAN
adc.read_timed(buf, tim)     # Lancement des mesures

# Mise en forme des données
f = tim.freq()
x = [i*1/f for i in range(nb)]
y = [val for val in buf]

# transmission des données
data = x, y    # Tuple de données
print(data)    # Affichage du tuple dans le REPL
"""

feather = Pyboard("/dev/ttyACM0")
x, y = feather.exec_script_to_data(script)

t = np.array(x)
u = np.array(y)
rate = 20000

plt.subplot(2, 1, 1)
plt.plot(t, u, 'r')
plt.grid()
#plt.ylim(0,4000)

plt.subplot(2, 1, 2)
spectre = np.absolute(fft(y))
#spectre = spectre/spectre.max()
n = spectre.size
Пример #3
0
from physique import Pyboard
feather = Pyboard("/dev/ttyACM0")
reponse = feather.exec_file("hello.py")
print(reponse)
Пример #4
0
from physique import Pyboard

programme = """
from pyb import LED
from time import sleep_ms

for i in range(10):
    LED(1).toggle()
    sleep_ms(500)
"""

feather = Pyboard("/dev/ttyACM0")
feather.exec_script(programme)
# Loi de Mariotte
# Capteur de pression absolue Adafruit MPRLS
# 0 - 25 PSI
# Seringue 20 mL
# David THERINCOURT - 05/2020

from physique import Pyboard, exportTxt

pyb = Pyboard("/dev/ttyACM0")      # Declaration de la carte Pyboard
pyb.enter_raw_repl()               # Entre dans le mode REPL
pyb.exec("""
from machine import I2C
from mprls import MPRLS
i2c = I2C(1)        # Premier port I2C
mprls = MPRLS(i2c, p_max=1724)  # Declaration du capteur de pression
""")


V = [60,50,40,35,30,25] # V = 40 mL pour pression atmosphérique
P = []

for vol in V :
    input("Regler le volume sur : " + str(vol) + " mL")
    output = pyb.exec("print(mprls.read())")   # Lecture de la pression
    pression = eval(output)                        # Conversion de string en float
    print(pression)                                # Affichage de la pression
    P.append(pression)                             # Ajout de la mesure dans le tableau

pyb.exit_raw_repl()                # Fermeture du mode REPL
pyb.close()                        # Deconnexion de la carte Pyboard
Пример #6
0
from physique import Pyboard

pyb = Pyboard("/dev/ttyACM0")

pyb.enter_raw_repl()
pyb.exec_("print('Hello')")
pyb.exit_raw_repl()

pyb.close()