Advertisement
Lonely_Wanderer

Умный дом. Датчики. 3 задача

Sep 16th, 2023
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. angle_sensor = unit.get(unit.ANGLE, unit.PORTB)
  2.  
  3. label0 = M5TextBox(96, 113, "label0", lcd.FONT_Default, 0xFFFFFF, rotate =0)
  4.  
  5.  
  6. # первый вариант
  7. while True:
  8.   angle = angle_sensor.read()
  9.   if 0 <= angle < 256:
  10.     label0.setText("1")
  11.   elif 256 <= angle < 512:
  12.     label0.setText("2")
  13.   else:
  14.     label0.setText("3")
  15.  
  16.  
  17. # второй вариант
  18. while True:
  19.   angle = angle_sensor.read()
  20.   if 0 <= angle < 256:
  21.     label0.setText("1")
  22.   elif 256 <= angle < 512:
  23.     label0.setText("2")
  24.   elif 512 <= angle < 1024:
  25.     label0.setText("3")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement