示例#1
0
    def __init__(self):
        # Create the MCP input
        self.mcp = MCP3008(spi=SPI(self.spi_port, self.spi_device))

        # Create the LCD output
        self.lcd = LCD(self.lcd_rs, self.lcd_en, self.lcd_d4, self.lcd_d5,
                       self.lcd_d6, self.lcd_d7, self.lcd_columns,
                       self.lcd_rows)
示例#2
0
 def __init__(self, lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
              lcd_columns, lcd_rows, lcd_backlight):
     self.lcd = LCD(lcd_rs,
                    lcd_en,
                    lcd_d4,
                    lcd_d5,
                    lcd_d6,
                    lcd_d7,
                    lcd_columns,
                    lcd_rows,
                    lcd_backlight,
                    gpio=aGPIO.get_platform_gpio())
     self.lcd.clear()
     self._columns = lcd_columns
     self._in_progress = None
示例#3
0
def pessoa_saiu():
    global horaChegada
    if (datetime.now() - horaChegada >= timedelta(seconds=10)):
        dados = {"chat_id": id_da_conversa, "text": "Pessoa saiu!"}
        resposta = post(endereco_mensagem, json=dados)
    

# criação de componentes
botao1 = Button(11)
botao2 = Button(12)
botao3 = Button(13)
buzzer = Buzzer(16)

led1 = LED(21)

lcd = LCD(2, 3, 4, 5, 6, 7, 16, 2)

player = Player()

sensor = DistanceSensor(trigger=17, echo=18)
sensor.threshold_distance = 0.2

botao1.when_pressed = ligar_campainha
botao1.when_released = enviar_mensagem

botao2.when_pressed = led1.off

botao3.when_pressed = iniciar_gravacao
botao3.when_released = parar_gravacao

sensor.when_in_range = pessoa_porta
示例#4
0
lcd_cols = 16
lcd_rows = 2

hit_target = False

state_not_started = 1
state_pre_culture = 2
state_waiting_culture = 3
state_incubation = 4
state_done = 5
rampUpDown = 1  #1 is a ramp up temp, 2 is a ramp down temp

state = state_not_started
# Initialize the LCD using the pins above.
lcd = LCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_cols, lcd_rows,
          lcd_backlight)

# Print a two line message
lcd.message('Yogurt Pi')


def setTemp(T):
    global hit_target
    global finishTime
    if (temp_f < T):
        if (rampUpDown == 2):
            if (hit_target == False):
                hit_target = True
                if (state == state_pre_culture):
                    sendTextMessage('Add Culture to the Yogurt')
        #turn on the heater
示例#5
0
def get_ip_addr():
    ip_addrs = check_output(CMD, shell=True,
                            universal_newlines=True).strip().split("\n")
    ip_addr = ip_addrs[0].split("/")[0]
    return ip_addr


def get_now():
    now = datetime.now().strftime('%b %d - %H:%M:%S')
    return now


lcd = LCD(
    rs=25,
    en=24,  # LCD #4 and #6, respectively
    d4=23,
    d5=17,
    d6=18,
    d7=22,  # LCD pins #11, #12, #13, #14
    cols=16,
    lines=2)
# Connect potentiometer to #3 (V0) for backlight brightness control.
# #15 and #16 power the backlight (5V and GND, respectively)

while True:
    lcd.clear()
    lcd.message(get_now())
    lcd.message('IP: %s' % get_ip_addr())
    sleep(1)
示例#6
0
文件: lcd.py 项目: silver2row/BBB-Bot
#!/usr/bin/python
import Adafruit_BBIO.GPIO as GPIO
from Adafruit_CharLCD import Adafruit_CharLCD as LCD

lcd = LCD(pin_rs="P8_31",
          pin_e="P8_32",
          pins_db=["P8_27", "P8_28", "P8_29", "P8_30"])
lcd.begin(16, 2)
lcd.clear()
lcd.message("  Adafruit 16x2\n  Standard LCD")