0% found this document useful (0 votes)
52 views7 pages

Micro Bit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views7 pages

Micro Bit

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Activité1 :

Exercice1

from microbit import *

while True:
display.show("1")
sleep(500)
display.show(" ")
sleep(500)

Activité 2 :
Exercice 1 :

from microbit import *

for x in range(5):
display.set_pixel(x,0,9)
sleep(500)

Exercice 2 :

from microbit import *

for x in range(5):
display.set_pixel(2,x,9)
sleep(500)

Exercice 3 :

from microbit import *

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

from microbit import *


from random import randint

for x in range(5):
for y in range(5):

display.set_pixel(x,y,randint(0,9))
sleep(500)

exercice 6

from microbit import *


def carre(l, color):
for x in range(5-l,l):
for y in range(5-l,l):
display.set_pixel(x,y,color)
carre(3,9)

from microbit import *


def carre(l, color):
for x in range(5-l,l):
for y in range(5-l,l):
display.set_pixel(x,y,color)
carre(4,9)

from microbit import *


def carre(l, color):
for x in range(5-l,l):
for y in range(5-l,l):
display.set_pixel(x,y,color)
carre(5,9)
exercice 7

from microbit import *


def carre(l, color):
for x in range(5-l,l):
for y in range(5-l,l):
display.set_pixel(x,y,color)
carre(3,9)
sleep(500)
carre(4,9)
sleep(500)
carre(5,9)
sleep(500)

exercice 8

from microbit import *

compteur = 0
while True:
if button_a.was_pressed():
display.show(str(compteur))
sleep(1000)
display.clear()

la carte affiche 0

exercice 9

from microbit import *

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

from microbit import *

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

from microbit import *

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)

x = max(0, min(x, 4))

dy = accelerometer.get_y()
y = 2 +(dy//150)
y = max(0, min(y, 4))
display.set_pixel(x,y,9)
sleep(20)
exercice 12

from microbit import *

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)

x = max(0, min(x, 4))

dy = accelerometer.get_y()
y = 2 +(dy//150)
y = max(0, min(y, 4))
display.set_pixel(x,y,9)
sleep(20)

exercice 13

from microbit import *

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)

Elles sont codées en diagonal descendant vers le bas a droite.


exercice 14

from microbit import *

imgs = [
Image('99999:90009:90009:90009:99999:'),
]
display.show(imgs,delay=500,loop=True)

exercice 15

from microbit import *


from random import choice

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

from microbit import *


from random import choice

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)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy