Do you want to know how to move custom-made pixel patterns in LCD ? Here it is :
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int movL,movR; int i=0;
byte pixels[8] = {
B11111,
B10001,
B11011,
B10001,
B11111,
B01010,
B01010,
B01010
};
void setup() {
pinMode(14,INPUT_PULLUP);
pinMode(15,INPUT_PULLUP);
lcd.createChar(0, pixels);
lcd.begin(16, 2);
lcd.write(byte(0));
}
void loop() {
movL=digitalRead(14);
movR=digitalRead(15);
if(movL==0)
{
i++;
lcd.clear();
lcd.setCursor(i,0);
lcd.write(byte(0));
delay(200);
}
if(movR==0)
{
i--;
lcd.clear();
lcd.setCursor(i,0);
lcd.write(byte(0));
delay(200);
}
}
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int movL,movR; int i=0;
byte pixels[8] = {
B11111,
B10001,
B11011,
B10001,
B11111,
B01010,
B01010,
B01010
};
void setup() {
pinMode(14,INPUT_PULLUP);
pinMode(15,INPUT_PULLUP);
lcd.createChar(0, pixels);
lcd.begin(16, 2);
lcd.write(byte(0));
}
void loop() {
movL=digitalRead(14);
movR=digitalRead(15);
if(movL==0)
{
i++;
lcd.clear();
lcd.setCursor(i,0);
lcd.write(byte(0));
delay(200);
}
if(movR==0)
{
i--;
lcd.clear();
lcd.setCursor(i,0);
lcd.write(byte(0));
delay(200);
}
}
留言
張貼留言