2022年7月10日日曜日

LearningKit 2022 for all Pico


 

# all_pico_wiper_lcd.py

# red-pin40 VBUS brown-GND orange-pin0

from machine import Pin, PWM

import utime

from esp8266_i2c_lcd import I2cLcd


pwm = PWM(Pin(2))

pwm.freq(50)


I2C_ADDR = 0x27

sda=Pin(0)

scl=Pin(1)


def servo_value(degree):

    return int((degree * 9.5 / 180 + 2.5) * 65535 / 100)


              

while True:

    i2c=machine.I2C(0,sda=sda,scl=scl,freq=400000)

    lcd=I2cLcd(i2c,I2C_ADDR,2,16)

    lcd.putstr("Hello,world!\n I am a pico")

    utime.sleep(0.1)  

    

    pwm.duty_u16(servo_value(20))

    utime.sleep(1)

    pwm.duty_u16(servo_value(160))

    utime.sleep(1)


0 件のコメント:

コメントを投稿