-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplant.py
More file actions
42 lines (27 loc) · 1.02 KB
/
plant.py
File metadata and controls
42 lines (27 loc) · 1.02 KB
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
42
from microbit import *
import log
import power
def echelle(value, in_min, in_max, out_min, out_max):
valeur = (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
return int(valeur)
@run_every(min=15)
def log_data():
log.add({
'humidite': pin0.read_analog(),
'temperature': temperature(),
'lumiere': display.read_light_level()
})
while True:
#display.set_pixel(x,y,valeur_lumiere)
if button_a.is_pressed() and button_b.is_pressed():
lumiere = echelle(display.read_light_level(), 0, 255, 0, 9)
print (lumiere)
display.show(lumiere)
if button_a.is_pressed():
display.scroll(temperature())
if button_b.is_pressed():
humid= echelle(pin0.read_analog(),0,800,0,9)
display.show(humid)
# To go sleep, wake up when button A is pressed, and ensure the
# function scheduled with run_every still executes in the background
power.deep_sleep(wake_on=button_a, run_every=True)