Advertisement
CatNamedWill

Fancy stepcounter

Jun 6th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. from microbit import *
  2. import radio
  3. radio.config(group=1)
  4. steps=0
  5. stepcounter=0
  6. dailystepbeep=20
  7. while True:
  8.    
  9.     message=radio.receive()
  10.     if message:
  11.        if message=='short':
  12.            dailystepbeep-=10
  13.        if message=='long':
  14.            dailystepbeep+=10
  15.     if accelerometer.was_gesture('shake'):
  16.        steps += 1
  17.        stepcounter+=1
  18.        radio.send('+1')
  19.     if steps==dailystepbeep:
  20.         radio.send('you have reached your daily goal')
  21.         steps=0
  22.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement