Advertisement
cmass

소리감응얼굴_UP

Nov 18th, 2019
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. from microbit import *
  2.  
  3. while True:
  4.     sound = pin0.read_analog()
  5.        
  6.     if sound<=100:
  7.         volume = 0
  8.     elif sound<=200:
  9.         volume = 1
  10.     elif sound<=300:
  11.         volume = 2
  12.     elif sound<=400:
  13.         volume = 3
  14.     elif sound<=500:
  15.         volume = 4
  16.     elif sound<=600:
  17.         volume = 5
  18.     elif sound<=700:
  19.         volume = 6
  20.     elif sound<=800:
  21.         volume = 7
  22.     elif sound<=900:
  23.         volume = 8
  24.     else:
  25.         volume = 9
  26.     for a in range(5):
  27.         for b in range(5):
  28.             display.set_pixel(a, b, volume)
  29.     sleep(1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement