Compare commits
5 Commits
98fd5f6742
...
d803fd81a5
Author | SHA1 | Date |
---|---|---|
Jimmy | d803fd81a5 | |
Jimmy | de247b3354 | |
Jimmy | 164d686df3 | |
Jimmy | 4b49cfc8b5 | |
Jimmy | a5547b3b45 |
|
@ -0,0 +1,10 @@
|
|||
from machine import Pin
|
||||
from time import sleep
|
||||
|
||||
button = Pin(13, Pin.IN) #D7
|
||||
button2 = Pin(14, Pin.IN) #d5
|
||||
|
||||
while True:
|
||||
print(button.value(), button2.value())
|
||||
sleep(1)
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
import dht
|
||||
import machine
|
||||
d = dht.DHT11(machine.Pin(16))
|
||||
d = dht.DHT11(machine.Pin(12))
|
||||
|
||||
d.measure()
|
||||
print(d.temperature())
|
||||
print(d.humidity())
|
||||
try:
|
||||
d.measure()
|
||||
print(d.temperature())
|
||||
print(d.humidity())
|
||||
except Exception as e:
|
||||
print(e)
|
|
@ -0,0 +1,17 @@
|
|||
from machine import Pin
|
||||
from time import sleep
|
||||
|
||||
led = Pin(2, Pin.OUT)
|
||||
|
||||
def callback(p):
|
||||
print('pin change', p, p.value())
|
||||
sleep(0.1)
|
||||
|
||||
button1 = Pin(13, Pin.IN)
|
||||
button1.irq(trigger=Pin.IRQ_FALLING, handler=callback)
|
||||
|
||||
button2 = Pin(14, Pin.IN)
|
||||
button2.irq(trigger=Pin.IRQ_FALLING, handler=callback)
|
||||
|
||||
while True:
|
||||
pass
|
|
@ -1,5 +1,8 @@
|
|||
from machine import ADC
|
||||
from time import sleep
|
||||
|
||||
ldr = ADC(0)
|
||||
|
||||
print(ldr.read())
|
||||
while True:
|
||||
print(ldr.read())
|
||||
sleep(1)
|
|
@ -0,0 +1,15 @@
|
|||
from machine import Pin
|
||||
from machine import PWM
|
||||
from time import sleep
|
||||
|
||||
led = PWM(Pin(0, Pin.OUT))
|
||||
|
||||
for i in range(-1, 1024, 8):
|
||||
led.duty(i)
|
||||
print(i)
|
||||
sleep(0.1)
|
||||
|
||||
for i in range(1023, -1, -8):
|
||||
led.duty(i)
|
||||
print(i)
|
||||
sleep(0.1)
|
|
@ -0,0 +1,17 @@
|
|||
from machine import Pin
|
||||
from time import sleep
|
||||
|
||||
blue = Pin(0, Pin.OUT)
|
||||
green = Pin(4, Pin.OUT)
|
||||
red = Pin(5, Pin.OUT)
|
||||
|
||||
blue.off()
|
||||
red.on()
|
||||
sleep(1)
|
||||
red.off()
|
||||
green.on()
|
||||
sleep(1)
|
||||
green.off()
|
||||
blue.on()
|
||||
sleep(1)
|
||||
blue.off()
|
Loading…
Reference in New Issue