Micro Bit
Micro Bit
Exercice1
while True:
display.show("1")
sleep(500)
display.show(" ")
sleep(500)
Activité 2 :
Exercice 1 :
for x in range(5):
display.set_pixel(x,0,9)
sleep(500)
Exercice 2 :
for x in range(5):
display.set_pixel(2,x,9)
sleep(500)
Exercice 3 :
for x in range(5):
for y in range(5):
display.set_pixel(x,y,9)
sleep(500)
exercice4
from microbit import *
for x in range(5):
for y in range(5):
display.set_pixel(x,y,9)
sleep(500)
exercice 5
for x in range(5):
for y in range(5):
display.set_pixel(x,y,randint(0,9))
sleep(500)
exercice 6
exercice 8
compteur = 0
while True:
if button_a.was_pressed():
display.show(str(compteur))
sleep(1000)
display.clear()
la carte affiche 0
exercice 9
compteur = 0
while True:
if button_a.was_pressed():
compteur += 1
display.show(str(compteur))
sleep(100)
display.clear()
if button_b.was_pressed():
compteur = 0
sleep(100)
exercice 10
x=0
y=0
while True:
display.set_pixel(x,y,0)
if button_a.was_pressed():
x=x-1
if button_b.was_pressed():
x=x+1
x = max(0, min(x, 4))
display.set_pixel(x,y,9)
sleep(20)
exercice 11
x=0
y=0
while True:
display.set_pixel(x,y,0)
if button_a.was_pressed():
x=x-1
if button_b.was_pressed():
x=x+1
dx = accelerometer.get_x()
x = 2 +(dx//150)
dy = accelerometer.get_y()
y = 2 +(dy//150)
y = max(0, min(y, 4))
display.set_pixel(x,y,9)
sleep(20)
exercice 12
x=0
y=0
while True:
display.set_pixel(x,y,0)
if button_a.was_pressed():
x=x-1
if button_b.was_pressed():
x=x+1
dx = accelerometer.get_x()
x = 2 +(dx//150)
dy = accelerometer.get_y()
y = 2 +(dy//150)
y = max(0, min(y, 4))
display.set_pixel(x,y,9)
sleep(20)
exercice 13
imgs = [
Image('90000:00000:00000:00000:00000:'),
Image('90000:09000:00000:00000:00000:'),
Image('90000:09000:00900:00000:00000:'),
Image('90000:09000:00900:00090:00000:'),
Image('90000:09000:00900:00090:00009:'),
]
display.show(imgs,delay=500,loop=True)
imgs = [
Image('99999:90009:90009:90009:99999:'),
]
display.show(imgs,delay=500,loop=True)
exercice 15
mesImages = [Image('00000:00000:00900:00000:00000:'),
Image('00009:00000:00000:00000:90000:'),
Image('00009:00000:00900:00000:90000:'),
Image('90009:00000:00000:00000:90009:'),
Image('90009:00000:00900:00000:90009:'),
Image('90009:00000:90009:00000:90009:')]
while True:
if button_a.was_pressed():
rolled = choice(mesImages)
display.show(rolled)
exercice 16
mesImages = [Image('99999:99999:99999:99999:99999:'),
Image('99009:99090:00900:99090:99009:'),
Image('09999:09999:09999:09999:90000:'),
]
while True:
if button_a.was_pressed():
rolled = choice(mesImages)
display.show(rolled)
sleep(100)