#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int pushButton = 7;
int x = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
pinMode(pushButton, INPUT);
lcd.begin();
lcd.backlight();
lcd.setCursor(0,0);
}
void loop()
{
int i;
char a1,a2;
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>=10) x=0;
}
Serial.print(x);
delay(100);
}
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int pushButton = 7;
int x = 0;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
pinMode(pushButton, INPUT);
lcd.begin();
lcd.backlight();
lcd.setCursor(0,0);
}
void loop()
{
int i;
char a1,a2;
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==10){
x=0;
}
Serial.print(x);
delay(100);
}
看修改成紅色那3行看看.....
歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/) | Powered by Discuz! X3.2 |