Added 4 December Scripts
This commit is contained in:
parent
7825d5fff2
commit
1d31318c7b
28
4-dezember-led-blinken.py
Normal file
28
4-dezember-led-blinken.py
Normal file
@ -0,0 +1,28 @@
|
||||
from machine import ADC, Pin, PWM
|
||||
import time
|
||||
|
||||
# Anschluss Poti an GP27 und an Plus 3.3 Volt und Minus
|
||||
poti = ADC(Pin(27))
|
||||
|
||||
# LED
|
||||
gruen = PWM(Pin(18))
|
||||
gelb = PWM(Pin(19))
|
||||
rot = PWM(Pin(20))
|
||||
|
||||
# Variable mdelay = 0
|
||||
gruen.freq(1000)
|
||||
gelb.freq(1000)
|
||||
rot.freq(1000)
|
||||
|
||||
reading = 0
|
||||
|
||||
while True:
|
||||
|
||||
reading = poti.read_u16()
|
||||
print(reading)
|
||||
gruen.duty_u16(reading)
|
||||
gelb.duty_u16(reading)
|
||||
rot.duty_u16(reading)
|
||||
time.sleep(0.001)
|
||||
|
||||
|
28
4-dezember-led-regelung.py
Normal file
28
4-dezember-led-regelung.py
Normal file
@ -0,0 +1,28 @@
|
||||
from machine import ADC, Pin, PWM
|
||||
import time
|
||||
|
||||
# Anschluss Poti an GP27 und an Plus 3.3 Volt und Minus
|
||||
poti = ADC(Pin(27))
|
||||
|
||||
# LED
|
||||
gruen = PWM(Pin(18))
|
||||
gelb = PWM(Pin(19))
|
||||
rot = PWM(Pin(20))
|
||||
|
||||
# Variable mdelay = 0
|
||||
gruen.freq(1000)
|
||||
gelb.freq(1000)
|
||||
rot.freq(1000)
|
||||
|
||||
reading = 0
|
||||
|
||||
while True:
|
||||
|
||||
reading = poti.read_u16()
|
||||
print(reading)
|
||||
gruen.duty_u16(reading)
|
||||
gelb.duty_u16(reading)
|
||||
rot.duty_u16(reading)
|
||||
time.sleep(0.001)
|
||||
|
||||
|
14
README.md
14
README.md
@ -25,5 +25,19 @@ Today you have learnt:
|
||||
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
|
||||
Day 4 Complete!
|
||||
|
||||
Well done makers! We know today was a little heavier as we introduced slightly more advanced topics such as analogue and PWM, so take the time to go back over today's examples and play with the code if you'd like more practice - make it, break it, fix it, learn!
|
||||
|
||||
Today you have:
|
||||
|
||||
Learnt about analogue and the difference between analogue and digital signals
|
||||
Built a circuit with a potentiometer
|
||||
Leant how to use the ADC built into the Raspberry Pi Pico
|
||||
Controlled LEDs with an analogue signal
|
||||
Learnt about PWM including duty cycle and frequency
|
||||
|
||||
------------------------------------------------------------------------------------------------------
|
||||
|
||||
<img src="https://git.unixweb.net/unixweb/pihut-advent-kalender/raw/branch/master/images/pihut-advent-kalender.jpg">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user