read sensor

This commit is contained in:
Rob 2022-11-03 00:07:52 +01:00
commit e4411e85af
4 changed files with 54 additions and 0 deletions

9
boot.py Normal file
View File

@ -0,0 +1,9 @@
# Complete project details at https://RandomNerdTutorials.com
import esp
esp.osdebug(None)
import gc
gc.collect()
#import connectwifi
#import webserver

20
leds.py Normal file
View File

@ -0,0 +1,20 @@
"""
Functions to easy control LED
"""
# general imports
from machine import Pin, PWM
from time import sleep
def SmoothBlink():
frequency = 5000
led = PWM(Pin(2), frequency)
while True:
for duty_cycle in range(0, 1024):
led.duty(duty_cycle)
sleep(0.005)
for duty_cycle in reversed(range(0, 1024)):
led.duty(duty_cycle)
sleep(0.005)

15
main.py Normal file
View File

@ -0,0 +1,15 @@
#std lib
#import time
#custom libs
# import leds
# leds.SmoothBlink()
# read analog pin
from time import sleep
from machine import Pin, PWM, ADC
analog = ADC(0)
while True:
print(analog.read())
sleep(1)

10
pymakr.conf Normal file
View File

@ -0,0 +1,10 @@
{
"py_ignore": [
".vscode",
".gitignore",
".git",
"env",
"venv"
],
"name": "FeuchtigkeitsSensor"
}