Advertisement
ABIX_Edukacja

PyTechBrain - potencjometr i dioda PWM

Jun 4th, 2019
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. # Kod źródłowy dla lekcji: Plotter z potencjometru + dioda PWM
  2. # należy pamiętać, aby przed uruchomieniem w Mu-Editor włączyć tryb "Plotter"
  3. # Autor: Adam Jurkiewicz, ABIX Edukacja https://pytechbrain.edu.pl
  4. #
  5. from PyTechBrain import *
  6. from time import sleep
  7. uklad = PyTechBrain()
  8.  
  9. while True:
  10.     sleep(0.1)
  11.     a = uklad.potencjometr_raw() # wczytujemy wartość wychylenia potencjometru
  12.     b = int( (a/1023) * 255)
  13.     uklad.PWM_modulacja(b) # wysyłamy przeliczoną wartość do diody PWM
  14.     print( (a,b) ) # wyświetlamy obie wartości w module "Plotter"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement