clase 3 de 2 quimestre-primera unidad
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pinFotocelda=A0;
int vidas=3;
byte corazon_izq[8]={ 0b00000000,
0b00000001,
0b00000011,
0b00000011,
0b00000001,
0b00000000,
0b00000000,
0b00000000
} ;
byte corazon_der[8]={0b00000000,
0b00000010,
0b00010111,
0b00011111,
0b00011110,
0b00011100,
0b00001000,
0b00000000
} ;
void setup() {
lcd.begin(16, 2); // Fijamos el numero de caracteres y filas
pinMode(pinFotocelda,INPUT);
lcd.createChar(1,corazon_izq);
lcd.createChar(2,corazon_der);
}
void loop() {
int dato=analogRead(pinFotocelda);
delay(1000);
if(dato<300 p="">
{
vidas=vidas-1;
}
if(vidas==0)
{
lcd.clear();
lcd.setCursor(1, 1); // Ponte en la line 1, posicion 1
lcd.print("Game Over") ;
delay(5000)
vidas=3;
}
lcd.setCursor(0,0);
printVidas();
}
void printVidas(){
if(vidas==3)
{
lcd.clear();
lcd.write(1);
lcd.write(2);
lcd.write(1);
lcd.write(2);
lcd.write(1);
lcd.write(2);
}
else if(vidas==2){
}
}300>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pinFotocelda=A0;
int vidas=3;
byte corazon_izq[8]={ 0b00000000,
0b00000001,
0b00000011,
0b00000011,
0b00000001,
0b00000000,
0b00000000,
0b00000000
} ;
byte corazon_der[8]={0b00000000,
0b00000010,
0b00010111,
0b00011111,
0b00011110,
0b00011100,
0b00001000,
0b00000000
} ;
void setup() {
lcd.begin(16, 2); // Fijamos el numero de caracteres y filas
pinMode(pinFotocelda,INPUT);
lcd.createChar(1,corazon_izq);
lcd.createChar(2,corazon_der);
}
void loop() {
int dato=analogRead(pinFotocelda);
delay(1000);
if(dato<300 p="">
{
vidas=vidas-1;
}
if(vidas==0)
{
lcd.clear();
lcd.setCursor(1, 1); // Ponte en la line 1, posicion 1
lcd.print("Game Over") ;
delay(5000)
vidas=3;
}
lcd.setCursor(0,0);
printVidas();
}
void printVidas(){
if(vidas==3)
{
lcd.clear();
lcd.write(1);
lcd.write(2);
lcd.write(1);
lcd.write(2);
lcd.write(1);
lcd.write(2);
}
else if(vidas==2){
}
}300>
Comentarios
Publicar un comentario