#include "pico/stdlib.h"
#include "lcd.h"
#define BUTTON_PIN 15
#define I2C_PORT i2c0
#define SDA_PIN 0
#define SCL_PIN 1
int main() {
stdio_init_all();
// Button init
gpio_init(BUTTON_PIN);
gpio_set_dir(BUTTON_PIN, false);
gpio_pull_up(BUTTON_PIN);
// I2C init
i2c_init(I2C_PORT, 100 * 1000);
gpio_set_function(SDA_PIN, GPIO_FUNC_I2C);
gpio_set_function(SCL_PIN, GPIO_FUNC_I2C);
gpio_pull_up(SDA_PIN);
gpio_pull_up(SCL_PIN);
// LCD init
lcd_init(I2C_PORT);
lcd_puts(I2C_PORT, "Smart Classroom");
while (1) {
if (gpio_get(BUTTON_PIN) == 0) {
lcd_clear(I2C_PORT);
lcd_puts(I2C_PORT, "accepted!");
sleep_ms(500); // show message for 0.5s
lcd_clear(I2C_PORT);
lcd_puts(I2C_PORT, "Smart Classroom");
while (gpio_get(BUTTON_PIN) == 0) sleep_ms(10); // wait release
}
}
}