#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int pushButton = 7;
int ledpin = 8;
int x = 0;
int t;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
pinMode(pushButton, INPUT);
pinMode(ledpin, OUTPUT);
lcd.begin();
lcd.backlight();
lcd.setCursor(0,0);
char s[] = {'b1','b2'};
int t = atoi(s);
}
void loop()
{
char a1,a2,b1,b2;
b1='8';
b2='1';
lcd.setCursor(1,1);
lcd.write(b1);
lcd.setCursor(0,1);
lcd.write(b2);
int i;
i = digitalRead(pushButton);
if(i == HIGH)
{
x++;
a1=x%10;
a2=(x/10)%10;
lcd.setCursor(1,0);
lcd.write(a1+'0');
lcd.setCursor(0,0);
lcd.write(a2+'0');
if (x>=20) x=0;
}
if( x >= t)
{
digitalWrite(ledpin, HIGH);
}
else
{
digitalWrite(ledpin, LOW);
}
}
歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) | Powered by Discuz! X3.2 |