-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (30 loc) · 668 Bytes
/
Copy pathmain.py
File metadata and controls
41 lines (30 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from microbit import *
from PiicoDev_SSD1306 import *
# --- SETUP
# start sensors
oled = create_PiicoDev_SSD1306()
# store variables
x = 10
y = 10
x_speed = 1
y_speed = 1
rect_width = 2
rect_height = 2
rect_colour = 1
# --- RUNNING
while True:
# read sensor data
# process data
# output data
oled.fill(0)
# Upsdate coordinate values
if x == 0 or x + 2 == 127:
x_speed = x_speed * -1
if y == 0 or y + 2 == 63:
y_speed = y_speed * -1
x += x_speed
y += y_speed
### Draw a square
oled.rect(x,y,rect_width,rect_height,rect_colour)
### Update display ###
oled.show()