示例#1
0
# Initialize the LCD using the pins above.
#lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
#lcd_columns, lcd_rows, lcd_backlight,False)

# Backlight pwm separately, is not supported by Adafruit
lcd = Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
                       lcd_columns, lcd_rows)

# Print a two line message
lcd.message('Hello\nworld!')

#GPIO.setmode(GPIO.BOARD)
GPIO.setup(lcd_backlight, GPIO.OUT)

# set frequency
p = GPIO.PWM(12, 400)
# Start with duty cycle (percentage)
p.start(100)
# set duty cycle
#p.ChangeDutyCycle(10.0)


def on_disconnect(client, userdata, rc=0):
    #logging.debug("DisConnected result code "+str(rc))
    client.loop_stop()


def on_message(client, userdata, message):
    print("message received ", str(message.payload.decode("utf-8")))
    print("message topic=", message.topic)
    print("message qos=", message.qos)