Create adc-svetloba.py

This commit is contained in:
kristjan-komlosi
2017-06-27 12:50:23 +02:00
committed by GitHub
parent 17a1625437
commit af3ee72a79

20
adc-svetloba.py Normal file
View File

@@ -0,0 +1,20 @@
from machine import ADC, Pin
import time
import math
adc=ADC(0)
tipka=Pin(12, Pin.IN, Pin.PULL_UP)
led=Pin(15, Pin.OUT)
#def korigiraj(x):
#popravi svetlobno lestvico iz nelinearnega adc
# v vsaj približno linearne lukse
while tipka.value():
svetlost=adc.read()
if svetlost<512:
led.value(1)
else:
led.value(0)
time.sleep_ms(500)
print("realni izhod: ", svetlost)
#print("korigirana vrednost: ")