Added three more effects:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
float w=0;
float u=0;
float t=0;
int xWidth = 16;
int yWidth = 4;
//y first, x second
byte dis[4][16] = {
{B1,B0,B0,B0,B1,B0,B1,B0,B0,B0,B0,B0,B0,B0,B0,B0 },
{B0,B0,B1,B0,B1,B0,B1,B0,B0,B0,B0,B0,B0,B0,B0,B0 },
{B0,B0,B1,B0,B0,B0,B1,B0,B0,B0,B0,B0,B0,B0,B0,B0 },
{B1,B0,B0,B0,B1,B0,B1,B0,B0,B0,B0,B0,B0,B0,B0,B0 },
};
static byte top[8] = {B11111,B11111,B11111,B11111,B00000,B00000,B00000,B00000};
static byte bot[8] = {B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};
static byte ful[8] = {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};
void setup() {
lcd.createChar(0,top);
lcd.createChar(1,bot);
lcd.createChar(2,ful);
lcd.begin(xWidth,yWidth/2);
updateDisplay();
}
void loop() {
while(w<500) {
fillDisplay(0);
for(int x=0;x<xWidth;x++) {
paint(x,2+2*cos(radians(w*(x+1))),1);
}
updateDisplay();
w+=0.5;
}
w=0;
while(w<50) {
fillDisplay(0);
for (int x=0;x<xWidth;x++) {
for (int y=0;y<yWidth;y++) {
u=255*cos(x)+255*sin(radians(w*y));//would look better on bigger display;Tested in Processing
u=(u>16)?1:0;
paint(x,y,u);
}
}
updateDisplay();
w+=0.1;
}
w=0;u=0;t=0;
while(t<520) {
w=40*cos(millis()/480)+70*cos(millis());
u+=(w-u)/50;
fillDisplay(0);
for (int x=0;x<xWidth;x++) {
paint(x,2+2*cos(radians(((1+x)*u)+millis()/20)),1);
}
t+=0.4;
updateDisplay();
}
w=0;u=0;
while(w<750) {
fillDisplay(0);
for (int x=0;x<xWidth;x++) {
for (int y=0;y<yWidth;y++) {
u=x^y;
u=(u<8+8*cos(radians(w)))?1:0;
paint(x,y,u);
}
}
updateDisplay();
w+=1.4;
}
w=0;u=0;
}
void fillDisplay(int c) {//0=white, 1=black, 2=invert
for (int x=0;x<=xWidth;x++) {
for (int y=0;y<=yWidth;y++) {
if(c==2){
dis[y][x]^=B1;
}
else{
dis[y][x]=(c==1)?B1:B0;
}
}
}
}
void paint(int x,int y,int c) {
x=round(x);
y=round(y);
if (x<17&&x>-1&&y>-1&&y<5) {
if(c==2){
dis[y][x]^=B1;
}
else{
dis[y][x]=(c==0)?B0:B1;
}
}
}
void updateDisplay() {
lcd.setCursor(0,0);
int r;
for (int i=0;i<=xWidth;i++) {
r=0;
r+=(dis[0][i]==B1)?1:0;
r+=(dis[1][i]==B1)?2:0;
lcd.write((r==0)?254:r-1);
}
lcd.setCursor(0,1);
for (int i=0;i<=xWidth;i++) {
r=0;
r+=(dis[2][i]==B1)?1:0;
r+=(dis[3][i]==B1)?2:0;
lcd.write((r==0)?254:r-1);
}
}