"""
Interface: galaxia
Nom du projet: Nouveau projet
Description: 
Toolbox: vittascience
Mode: code

Blocks: <xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="l7jr3x91V=Y/Wof1epl@">nb_ours</variable><variable id="!;TT274Kd4a$pwJyxV~5">capt_optique</variable><variable id="#7b4cY+Du(bTn5W*:8FE">t0</variable></variables><block type="on_start" id="N+8,*#k)ekjcr/faLjMN" x="20" y="20"><statement name="DO"><block type="variables_set" id="I5Z-/S*TJ,1q5:AfKsFA"><field name="VAR" id="l7jr3x91V=Y/Wof1epl@">nb_ours</field><value name="VALUE"><block type="math_number" id="m^ZVtHmaCBVhb~Jq;HqK"><field name="NUM">0</field></block></value><next><block type="variables_set" id="yY!N8.@ykQUA|Ou4qVxO"><field name="VAR" id="#7b4cY+Du(bTn5W*:8FE">t0</field><value name="VALUE"><block type="io_initChronometer_simple" id="(nc-PXkYzd3:5gQ4-_KA"></block></value></block></next></block></statement></block><block type="forever" id="nYo]6=/XlulZUNY%b`,1" x="10" y="228"><statement name="DO"><block type="variables_set" id="kd:F23.H162usdHhQspV"><field name="VAR" id="!;TT274Kd4a$pwJyxV~5">capt_optique</field><value name="VALUE"><block type="call_expression_return" id="-IrlWU{6z@k`}7*]m$Dd"><field name="NAME">p19</field><value name="chain"><block type="call_expression_editable_return" id="s9prhoPZ{d4U#B%ON+t3"><field name="NAME">value</field></block></value></block></value><next><block type="controls_if" id="g0xM%6n(Jn)*@|!=bp[;"><value name="IF0"><block type="logic_compare" id="h$kKk`q$xS;)ge|v-zdF"><field name="OP">EQ</field><value name="A"><block type="variables_get" id="+Qw.Lc`t6R_M0~U|=Y{~"><field name="VAR" id="!;TT274Kd4a$pwJyxV~5">capt_optique</field></block></value><value name="B"><block type="math_number" id="sA?Yq|:;?60~d2e:dlf3"><field name="NUM">1</field></block></value></block></value><statement name="DO0"><block type="variables_increment" id="XazA9QClwRDz2$T)(Dye"><field name="VAR" id="l7jr3x91V=Y/Wof1epl@">nb_ours</field><value name="DELTA"><block type="math_number" id="|#{XjGF5~V3Lod48f+ko"><field name="NUM">1</field></block></value><next><block type="communication_serialWrite" id="6OL6H+1$SRt[p}S?X:Y?"><mutation newlines="false"></mutation><value name="TEXT"><block type="text_join_simple" id="yCq@FSF4+)(Pr(2I=mA5"><mutation items="2"></mutation><value name="ADD0"><block type="text" id="`Q}Ws};80X7@-?%LU+0;"><field name="TEXT">Ours detecte(s)=</field></block></value><value name="ADD1"><block type="variables_get" id="lxQ@8bFHR4L~o%}aRDgy"><field name="VAR" id="l7jr3x91V=Y/Wof1epl@">nb_ours</field></block></value></block></value><next><block type="communication_serialWrite" id="aXjuUbev4PZm4;ueAlz|"><mutation newlines="false"></mutation><value name="TEXT"><block type="math_round" id="]wrhVzn6bH58EZ,+NQ)Z"><field name="OP">ROUND</field><value name="NUM"><block type="math_arithmetic" id="9p~({+a_lsKkJ;E7F3F]"><field name="OP">DIVIDE</field><value name="A"><block type="io_getChronometer" id="TJd)+YMPM6nw5Oxs%e@#"><field name="UNIT">MILLI</field></block></value><value name="B"><block type="math_number" id="kcxy~q0YbW~HwSku6)q3"><field name="NUM">1000</field></block></value></block></value></block></value><next><block type="io_pause" id="xv?{_oVr5PC+CvTMiraj"><field name="UNIT">SEC</field><value name="TIME"><block type="math_number" id=",[L],~8Adz=z0@J@Pu9G"><field name="NUM">1</field></block></value></block></next></block></next></block></next></block></statement></block></next></block></statement></block></xml>

Projet généré par Vittascience.
Ce fichier contient le code textuel ainsi que le code blocs. Il peut être importé de nouveau
sur l'interface http://vittascience.com/galaxia

"""

from machine import *
from thingz import *
import utime

p19 = Pin(13, Pin.IN)
nb_ours=0
t0 = utime.ticks_ms() 

while True:
  capt_optique = p19.value()
  if capt_optique == 1:
    nb_ours = nb_ours + 1
    print('Ours detecte(s)='+str(nb_ours))
    print(str(round(utime.ticks_diff(utime.ticks_ms(), t0)/1e3))) 
    utime.sleep(1)
