Project tutorial
Raiders of the Lost Key

Raiders of the Lost Key

Take the joystick and inmerse yourself in this epic adventure. One man in his search to gather the keys.

  • 675 views
  • 0 comments
  • 2 respects

Components and supplies

About this project

I've been making some experiments with my lcd 16 02 screen and I decided to make a little game to play it with a joystick.

Instructions:

left = left

right = right

up = jump

down = down

button = fly

Code

IndieArduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 7, 6, 5, 4);
int start = HIGH;
int salto = 0;
int avance = 0;
int avance2 = 0;
int salto2= 0;
int x = A2;
int y = A1;
int boton = 11;
int renglon = 0;
int columna = 0;
const int duracionsalto = 200;
int starton = 13;
int start2 = HIGH;
int bandera = 0;
int llave = 0;
int prueba = 0;
int nivel = 1;
int fua = 0;


byte normal[] = {
  B01110,
  B01110,
  B01110,
  B10101,
  B11111,
  B00100,
  B01110,
  B11011
};

byte aire[] = {
  B01110,
  B01110,
  B01110,
  B00100,
  B11111,
  B10101,
  B01110,
  B01010
};

byte blanco[] = {
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000,
  B00000
};
byte abajo[] = {
  B00000,
  B01110,
  B01110,
  B01110,
  B00100,
  B11111,
  B00100,
  B11011
};

byte giho[] = {
  B00000,
  B01110,
  B10001,
  B10001,
  B10001,
  B01010,
  B11011,
  B00000
};

byte obstaculo[] = {
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111,
  B11111
};

byte LLAVE[] = {
  B11111,
  B10011,
  B10011,
  B11011,
  B10011,
  B11011,
  B10101,
  B10001
};




void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.createChar(2, normal);
    lcd.createChar(4, blanco);
lcd.createChar(5, abajo);
  lcd.createChar(3, aire);
  lcd.createChar(6, giho);
  lcd.createChar(7, obstaculo);
  lcd.createChar(8, LLAVE);
  pinMode(boton, INPUT_PULLUP);
    pinMode(start, INPUT);

//  pinMode(x, INPUT);
  //pinMode(y, INPUT);

/*
  lcd.setCursor(1, 0);
  lcd.write(6);

  
lcd.setCursor(2, 0);
  lcd.print("idiana jones");
  lcd.setCursor(14, 0);
  lcd.write(6);

delay(2000);

for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}*/
}

void loop() {
  
int sensorReading = analogRead(A0);
int delayTime = map(sensorReading, 0, 1023, 200, 1000);
int salto = analogRead(x);
int avance = analogRead(y);
start = digitalRead(starton);

 /*Serial.print("x: ");
  Serial.println(salto);

  Serial.print("y; ");
  Serial.println(avance);

*/

  
  



  
if(start == HIGH){
  start2 = HIGH;
}

if(start == LOW && start2 == HIGH){
  for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}

bandera = 1;
  lcd.setCursor(1, 0);
  lcd.write(6);

  
lcd.setCursor(2, 0);
  lcd.print("idiana jones");
  lcd.setCursor(14, 0);
  lcd.write(6);

delay(2000);

for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}


columna = 0;
renglon = 0;
  start2 = start;
}





if(bandera == 1){
  
  if(nivel == 1){ //nivel 1

lcd.setCursor(5, 1);
  lcd.write(7);

  lcd.setCursor(11, 1);
  lcd.write(7);

   lcd.setCursor(15, 1);
  lcd.write(8);

  prueba = 0;

  
if(avance>600  &&  avance2 != avance){ 

lcd.setCursor(columna, renglon);
  lcd.write(4);

  renglon = 1;

  
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  delay(duracionsalto);
  lcd.setCursor(columna, renglon);
  lcd.write(4);
delay(duracionsalto);

  renglon = renglon - 1;
  columna = columna +1;

  lcd.setCursor(columna ,renglon);
  lcd.write(3);
delay(duracionsalto);

lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna + 1;
  renglon = renglon + 1;
  
  
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  


  avance2 = avance;

}

if(avance<300 && avance2 != avance){
  lcd.setCursor(columna, renglon);
  lcd.write(5);
  delay(duracionsalto);
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  renglon = 1;

lcd.setCursor(columna, 0);
  lcd.write(4);
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  avance2 = avance;
 
  
  
  
}


if(salto<300 && salto2 != salto){
  lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna + 1;
delay(duracionsalto);
lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  salto2 = salto;
  
  
}

if(salto>600 && salto2 != salto){
  lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna - 1;
delay(duracionsalto);
lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  salto2 = salto;
  
  
}

if(!digitalRead(boton)){
   lcd.setCursor(columna, renglon);
  lcd.write(4);
  renglon = 0;
  lcd.setCursor(columna ,renglon);
  lcd.write(3);
  delay(duracionsalto);
  lcd.setCursor(columna ,renglon);
  lcd.write(2);
  
}


/*Serial.println("c:");
  Serial.println(columna);

    Serial.println("r:");
  Serial.println(renglon);*/



  
if(columna == 16){
  columna = 0;
  renglon = 0;
}





if((columna == 5 && renglon == 1) || (columna == 11 && renglon == 1) && llave == 0) {
prueba = 1;}

if(prueba == 1){
for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}
lcd.setCursor(1, 0);
  lcd.write(6);

  
lcd.setCursor(2, 0);
  lcd.print("YOU LOOSE");
  lcd.setCursor(14, 0);
  lcd.write(6);
}



//llave

if(columna == 15 && renglon == 1){
  llave = 1;

  lcd.setCursor(2, 0);
  lcd.print("llave");
  lcd.setCursor(14, 0);
  lcd.write(6);
}



if(columna == 11 && renglon == 1 && llave == 1 && nivel == 1){
lcd.setCursor(2, 0);
  lcd.print("LEVEL 1 PASSED");
  lcd.setCursor(14, 0);
  lcd.write(6);
  delay(2000);
  for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}

  llave = 0;
  nivel = 2;
  fua = 1;
  prueba = 0;
  
}


}//nivel



//nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2 nivel 2



if(nivel == 2 ){

  if(fua == 1){
for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}


  lcd.setCursor(1, 0);
  lcd.write(6);

  
lcd.setCursor(2, 0);
  lcd.print("NIVEL 2");
  lcd.setCursor(14, 0);
  lcd.write(6);

delay(2000);

for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}

fua = 0;
columna = 0;
renglon = 0;
  }






//coniguracion de obstaculos
  lcd.setCursor(5, 1);
  lcd.write(7);

  lcd.setCursor(7, 1);
  lcd.write(7);

  lcd.setCursor(11, 1);
  lcd.write(7);
  lcd.setCursor(9, 0);
  lcd.write(7);

   lcd.setCursor(15, 1);
  lcd.write(8);
//configuracion de obstaculos fin
  prueba = 0;


  
if(avance>600  &&  avance2 != avance){ 

lcd.setCursor(columna, renglon);
  lcd.write(4);

  renglon = 1;

  
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  delay(duracionsalto);
  lcd.setCursor(columna, renglon);
  lcd.write(4);
delay(duracionsalto);

  renglon = renglon - 1;
  columna = columna +1;

  lcd.setCursor(columna ,renglon);
  lcd.write(3);
delay(duracionsalto);

lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna + 1;
  renglon = renglon + 1;
  
  
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  


  avance2 = avance;

}

if(avance<300 && avance2 != avance){
  lcd.setCursor(columna, renglon);
  lcd.write(5);
  delay(duracionsalto);
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  renglon = 1;

lcd.setCursor(columna, 0);
  lcd.write(4);
  lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  avance2 = avance;
 
  
  
  
}


if(salto<300 && salto2 != salto){
  lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna + 1;
delay(duracionsalto);
lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  salto2 = salto;
  
  
}

if(salto>600 && salto2 != salto){
  lcd.setCursor(columna, renglon);
  lcd.write(4);

  columna = columna - 1;
delay(duracionsalto);
lcd.setCursor(columna, renglon);
  lcd.write(2);
  
  salto2 = salto;
  
  
}

if(!digitalRead(boton)){
   lcd.setCursor(columna, renglon);
  lcd.write(4);
  renglon = 0;
  lcd.setCursor(columna ,renglon);
  lcd.write(3);
  delay(duracionsalto);
  lcd.setCursor(columna ,renglon);
  lcd.write(2);
  
}


/*Serial.println("c:");
  Serial.println(columna);

    Serial.println("r:");
  Serial.println(renglon);*/



  
if(columna>16){
  columna = 0;
  renglon = 0;
}


if(columna == 11 && renglon == 1 && llave == 1){

lcd.setCursor(2, 0);
  lcd.print("LEVEL 2 PASSED");
  lcd.setCursor(14, 0);
  lcd.write(6);
  delay(2000);
  for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}
  nivel = 3;

  
}


if(((columna == 5 && renglon == 1) || (columna == 11 && renglon == 1)|| (columna == 7 && renglon == 1) || (columna == 9 && renglon == 0))&& llave == 0) {
prueba = 1;}

if(prueba == 1){
for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 0);
   lcd.write(4);
}
 for(columna = 0; columna <= 16; columna++){
  lcd.setCursor(columna, 1);
   lcd.write(4);
}
lcd.setCursor(1, 0);
  lcd.write(6);

  
lcd.setCursor(2, 0);
  lcd.print("YOU LOOSE");
  lcd.setCursor(14, 0);
  lcd.write(6);
}



//llave

if(columna == 15 && renglon == 1){
  llave = 1;

  lcd.setCursor(2, 0);
  lcd.print("llave");
  lcd.setCursor(14, 0);
  lcd.write(6);
}







  
}//nivel2



Serial.print("columna: ");
Serial.println(columna);

Serial.print("renglon: ");
Serial.println(renglon);



Serial.print("llave: ");
Serial.println(llave);








}//badera


























}

Schematics

Comments

Similar projects you might like

Straight Key Morse Code Oscillator

Project tutorial by AC8XU

  • 5,661 views
  • 1 comment
  • 6 respects

Displaying Key Pressed on Serial Monitor

Project tutorial by ejshea

  • 5,783 views
  • 1 comment
  • 10 respects

An Alternate RFID Key for Bike Security

Project tutorial by Shubham Shinganapure

  • 7,931 views
  • 2 comments
  • 15 respects

Dodge The Defs!

Project tutorial by SRP888

  • 7,555 views
  • 21 comments
  • 12 respects

Telegram Bot with ESP8266

Project tutorial by Team CodersCafe

  • 64,288 views
  • 53 comments
  • 91 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 58,057 views
  • 19 comments
  • 86 respects
Add projectSign up / Login