Show Posts
|
|
Pages: [1]
|
|
2
|
Forum 2005-2010 (read only) / Español / Re: 3 en raya o Tic Tac Toe
|
on: December 26, 2010, 08:56:00 pm
|
Parte 3
/*********************************************************/ /***************condiciones de victoria*******************/ /*********************************************************/ void victoriaCirculo() { if ( celdas[0]==0 && celdas[1]==0 && celdas[2]==0 || celdas[3]==0 && celdas[4]==0 && celdas[5]==0 || celdas[6]==0 && celdas[7]==0 && celdas[8]==0 ) // las lineas horizontales { dequieneselpuntoCirculo(); } else if ( celdas[0]==0 && celdas[3]==0 && celdas[6]==0 || celdas[1]==0 && celdas[4]==0 && celdas[7]==0 || celdas[2]==0 && celdas[5]==0 && celdas[8]==0 ) // las lineas verticales { dequieneselpuntoCirculo(); } else if ( celdas[0]==0 && celdas[4]==0 && celdas[8]==0 || celdas[2]==0 && celdas[4]==0 && celdas[6]==0 ) // las lineas diagonales { dequieneselpuntoCirculo(); } }
void victoriaEquis() { if ( celdas[0]==1 && celdas[1]==1 && celdas[2]==1 || celdas[3]==1 && celdas[4]==1 && celdas[5]==1 || celdas[6]==1 && celdas[7]==1 && celdas[8]==1 ) // las lineas horizontales { dequieneselpuntoEquis(); } else if ( celdas[0]==1 && celdas[3]==1 && celdas[6]==1 || celdas[1]==1 && celdas[4]==1 && celdas[7]==1 || celdas[2]==1 && celdas[5]==1 && celdas[8]==1 ) // las lineas verticales { dequieneselpuntoEquis(); } else if ( celdas[0]==1 && celdas[4]==1 && celdas[8]==1 || celdas[2]==1 && celdas[4]==1 && celdas[6]==1 ) // las lineas diagonales { dequieneselpuntoEquis(); } }
void dequieneselpuntoCirculo(){ if (fichaJugador1==0){ //si el jugador 1 tiene el circulo, punto marcadorJugador1=marcadorJugador1+1; // sumo punto a marcador celdas[0]=2; // reinicio array celdas[1]=2; celdas[2]=2; celdas[3]=2; celdas[4]=2; celdas[5]=2; celdas[6]=2; celdas[7]=2; celdas[8]=2; GLCD.ClearScreen();
} else{//si el jugador 2 tiene el circulo, punto marcadorJugador2=marcadorJugador2+1; celdas[0]=2; celdas[1]=2; celdas[2]=2; celdas[3]=2; celdas[4]=2; celdas[5]=2; celdas[6]=2; celdas[7]=2; celdas[8]=2; GLCD.ClearScreen(); } }
void dequieneselpuntoEquis(){//si el jugador 1 tiene la equis, punto if (fichaJugador1==1){ marcadorJugador1=marcadorJugador1+1; celdas[0]=2; celdas[1]=2; celdas[2]=2; celdas[3]=2; celdas[4]=2; celdas[5]=2; celdas[6]=2; celdas[7]=2; celdas[8]=2; GLCD.ClearScreen(); } else{//si el jugador 2 tiene la equis, punto marcadorJugador2=marcadorJugador2+1; celdas[0]=2; celdas[1]=2; celdas[2]=2; celdas[3]=2; celdas[4]=2; celdas[5]=2; celdas[6]=2; celdas[7]=2; celdas[8]=2; GLCD.ClearScreen(); } }
|
|
|
|
|
3
|
Forum 2005-2010 (read only) / Español / Re: 3 en raya o Tic Tac Toe
|
on: December 26, 2010, 08:55:09 pm
|
Parte 2: /*********************************************************/ /****eleccion de celda pintando el valor en la celda******/ /************************* *******************************/
void elijeCelda() { val1 = map(analogRead(0), 0, 1023, 0, 9); // Map an analog value to 10 (0 a 9) numbers (pongo 9 porque al pulsar el boton, el tramo superior me lo asimila al anterior if // Celda 0 (val1==0 && celdas[0]==2) //si el potenciometro esta en la posicion 0, y el array me dice que no tengo un valor asignado { if (nowPlaying==0) // y estoy jugando con los ceros, { GLCD.DrawBitmap(o, 2,1, BLACK); //pinto el dibujo del 0 de forma TEMPORAL delay(1000); GLCD.DrawBitmap(blanco, 2,1, BLACK); //borro el dibujo del 0 if (digitalRead(12)==HIGH) // y si pulso, lo fijo en su lugar. { GLCD.DrawBitmap(o, 2,1, BLACK); //pinto el dibujo del 0 de forma FIJA nowPlaying=1; celdas[0]=0; delay(1000); } else{ }
} else if (nowPlaying==1) // y estoy jugando con las equis, repito lo mismo. {
GLCD.DrawBitmap(x, 2,1, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 2,1, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 2,1, BLACK); nowPlaying=0; celdas[0]=1; delay(1000); } } } // Celda 1 else if (val1==1 && celdas[1]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 24,1, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,1, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 24,1, BLACK); nowPlaying=1; celdas[1]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 24,1, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,1, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 24,1, BLACK); nowPlaying=0; celdas[1]=1; delay(1000); } } } // Celda 2 else if (val1==2 && celdas[2]==2) {
if (nowPlaying==0) { GLCD.DrawBitmap(o, 46,1, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,1, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 46,1, BLACK); nowPlaying=1; celdas[2]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 46,1, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,1, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 46,1, BLACK); nowPlaying=0; celdas[2]=1; delay(1000); } } } // Celda 3 else if (val1==3 && celdas[3]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 2,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 2,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 2,22, BLACK); nowPlaying=1; celdas[3]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 2,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 2,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 2,22, BLACK); nowPlaying=0; celdas[3]=1; delay(1000); } } } // Celda 4 else if (val1==4 && celdas[4]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 24,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 24,22, BLACK); nowPlaying=1; celdas[4]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 24,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 24,22, BLACK); nowPlaying=0; celdas[4]=1; delay(1000); } } } // Celda 5 else if (val1==5 && celdas[5]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 46,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 46,22, BLACK); nowPlaying=1; celdas[5]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 46,22, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,22, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 46,22, BLACK); nowPlaying=0; celdas[5]=1; delay(1000); } } } // Celda 6 else if (val1==6 && celdas[6]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 2,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 2,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 2,44, BLACK); nowPlaying=1; celdas[6]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 2,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 2,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 2,44, BLACK); nowPlaying=0; celdas[6]=1; delay(1000); } } } // Celda 7 else if (val1==7 && celdas[7]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 24,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 24,44, BLACK); nowPlaying=1; celdas[7]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 24,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 24,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 24,44, BLACK); nowPlaying=0; celdas[7]=1; delay(1000); } } } // Celda 8 y la 9 porque me asimila el ultimo valor al anterior, y entonces el 8 me lo asimilaria al 7 else if (val1==8 && celdas[8]==2 || val1==9 && celdas[8]==2) { if (nowPlaying==0) { GLCD.DrawBitmap(o, 46,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(o, 46,44, BLACK); nowPlaying=1; celdas[8]=0; delay(1000); } else{ } } else if (nowPlaying==1) { GLCD.DrawBitmap(x, 46,44, BLACK); delay(1000); GLCD.DrawBitmap(blanco, 46,44, BLACK); if (digitalRead(12)==HIGH) { GLCD.DrawBitmap(x, 46,44, BLACK); nowPlaying=0; celdas[8]=1; delay(1000); } } }
}
|
|
|
|
|
4
|
Forum 2005-2010 (read only) / Español / 3 en raya o Tic Tac Toe
|
on: December 26, 2010, 08:52:59 pm
|
Pues aqui esta el tres en raya para arduino, implementando el potenciometro que explique anteayer como modo de seleccion. De momento es para dos jugadores, mientras me curro como hacer que el bicho elija en condiciones. Pero bueno, por lo menos el juego funciona y es solo implementar la funcion de la IA. Graficos en http://rapidshare.com/files/439430584/tic_tac_toe.zip Video en: http://www.youtube.com/watch?v=qVByAYkbA9U Parte 1: /* 3 en raya or TIC TAC TOE You can play against other Human Player. Select Circle or X pushing one button and twisting a potenciometer. Hardware needed: - push button in digital pin 12 - potenciometer in analog pin 0 - 128x64 LCD with glcd library - Another Human to play! - Graphics in: http://rapidshare.com/files/439430584/tic_tac_toe.zip - Demo video in: http://www.youtube.com/watch?v=qVByAYkbA9U In a near future, I will create a new game against the machine! :) This code is in the public domain. Code by Hombrelobo, Timosoft Team. www.mundobocata.com
*/
#include <glcd.h> #include "fonts/Arial14.h" // proportional font #include "fonts/SystemFont5x7.h" // system font #include "bitmaps/tic_tac_toe_logo.h" // comienzo #include "bitmaps/player1win.h" #include "bitmaps/player2win.h" #include "bitmaps/blanco.h" //blanco para limpiar celdas #include "bitmaps/o.h" // circulo #include "bitmaps/x.h" //equis
int marcadorJugador1; int marcadorJugador2; int fichaJugador1; int fichaJugador2; int nowPlaying; // donde almaceno que ficha esta jugando ahora. int fichas=0; //eleccion de fichas int zumbador =12; // salida 12 digital zumbador int boton=11; // salida 11 digital boton de ok int election;// donde guardo el valor que decida con el boton ok. int celdas[] = { 2,2,2,2,2,2,2,2,2}; // declaro el array de 9 posiciones int selectVal; int val1;
void setup() { pinMode(boton, INPUT); pinMode(zumbador, OUTPUT); digitalWrite (zumbador, HIGH); GLCD.Init(NON_INVERTED); // initialise the library GLCD.SelectFont(System5x7); // select fixed width system font GLCD.ClearScreen(); digitalWrite (zumbador,LOW);// apago el zumbador }
void loop () { if (fichas==0) {
GLCD.CursorTo(2,0); // for LCD GLCD.Puts("Select Who Starts"); // for LCD GLCD.CursorTo(0,5); // for LCD GLCD.Puts("Move the Potenciom."); GLCD.CursorTo(0,6); // for LCD GLCD.Puts("LEFT RIGHT to Choose"); GLCD.CursorTo(0,7); // for LCD GLCD.Puts("Push Button to Select"); selectVal = map(analogRead(0), 0, 512, 0, 1); // Map an analog value to 2 numbers ( 0 to 1) delay(500); if (selectVal==0) //si el valor del potenciometro es 0 { GLCD.DrawBitmap(o, 50,15, BLACK); //muestra la ficha 0 if (digitalRead(12)==HIGH) // y si pulso el boton, fijo el valor { nowPlaying=0; //elijo la ficha o fichas=1; fichaJugador1=0; fichaJugador2=1; GLCD.ClearScreen(); GLCD.DrawBitmap(tic_tac_toe_logo, 0,0, BLACK); // pinta en pantalla el logo del juego delay(3000); GLCD.ClearScreen(); } } else{ GLCD.DrawBitmap(x, 50,15, BLACK); if (digitalRead(12)==HIGH) { nowPlaying=1; fichas=1; fichaJugador1=1; fichaJugador2=0; GLCD.ClearScreen(); GLCD.DrawBitmap(tic_tac_toe_logo, 0,0, BLACK); // pinta en pantalla el logo del juego delay(3000); GLCD.ClearScreen(); } } } else{ marcador(); } }
/*********************************************************/ /*************comprobacion de marcadores******************/ /*********************************************************/ void marcador() //comprueba el marcador del juego y si nadie ha ganado pinta la tabla. { if (marcadorJugador1==3) { GLCD.ClearScreen(); GLCD.DrawBitmap(player1win, 0,0, BLACK); //ganaste! return; } else if (marcadorJugador2==3){ GLCD.ClearScreen(); GLCD.DrawBitmap(player2win, 0,0, BLACK); // perdiste! return; } else{ pintaJuego(); // pinto escenario pintaMarcador(); //pinto marcadores elijeCelda(); //elijo celda victoriaCirculo(); //chequeo la victoria de Circulo victoriaEquis(); //chequeo la victoria de equis } }
/*********************************************************/ /***************pintando el escenario*********************/ /*********************************************************/ void pintaJuego() // queda libre del pixel x 67 en adelante para texto { //pintamos el tablero de juego GLCD.DrawLine( 0, 0, 0, 63, BLACK); //marco izquierdo GLCD.DrawLine( 22, 0, 22, 63, BLACK);//linea Vertical 1 GLCD.DrawLine( 44, 0, 44, 63, BLACK);//linea Vertical 2 GLCD.DrawLine( 66, 0, 66, 63, BLACK);//marco derecho GLCD.DrawLine( 0, 0, 66, 0, BLACK);//marco superior GLCD.DrawLine( 0, 21, 66, 21, BLACK);//linea Horizontal 1 GLCD.DrawLine( 0, 43, 66, 43, BLACK);//linea Horizontal 2 GLCD.DrawLine( 0, 63, 66, 63, BLACK);//marco inferior // pintando el cuadro del jugador activo GLCD.DrawLine( 102, 40, 126, 40, BLACK);//linea Horizontal 1 cuadrito activo GLCD.DrawLine( 102, 62, 126, 62, BLACK);//linea Horizontal 2 cuadrito activo GLCD.DrawLine( 102, 40, 102, 62, BLACK);//linea Vertical 1 cuadrito activo GLCD.DrawLine( 126, 40, 126, 62, BLACK);//linea Vertical 2 cuadrito activo }
/*********************************************************/ /*****************pintando marcador***********************/ /*********************************************************/ void pintaMarcador() // queda libre del pixel x 67 en adelante para texto { GLCD.CursorTo(12,0); // for LCD GLCD.Puts("Score1:"); // for LCD GLCD.PrintNumber(marcadorJugador1); // for LCD GLCD.CursorTo(12,1); // for LCD GLCD.Puts("Score2:"); // for LCD GLCD.PrintNumber(marcadorJugador2); // for LCD GLCD.CursorTo(12,3); // for LCD GLCD.Puts("Poten:"); // for LCD GLCD.PrintNumber(val1); // for LCD GLCD.CursorTo(13,6); // for LCD GLCD.Puts("NOW"); // for LCD
// pintando el jugador activo en el cuadrito if (nowPlaying==0) { GLCD.DrawBitmap(o, 105,41, BLACK); } else{ GLCD.DrawBitmap(x, 105,41, BLACK); } }
|
|
|
|
|
5
|
Forum 2005-2010 (read only) / Español / Potenciometro y boton para navegar en un menu
|
on: December 25, 2010, 01:53:21 pm
|
Hola! He desarrollado este código para el tres en raya que estoy diseñando. No he descubierto nada nuevo pero me ha costado unas vueltas. Te permite moverte con un potenciómetro por las opciones predefinidas, redondeando los valores del potenciómetro en torno a una cantidad de números que tu estipules (en mi caso 9, que son las celdas del juego) y un botón de ok que guarda la posición del potenciómetro. Os lo dejo para lo que os pueda servir. En concreto creo que es genial para moverse por cualquier tipo de menú. Salud! /* ************************************************************ * POTENCIOMETER AND "OK BUTTON" TO MOVE AROUND THE OPTIONS * ************************************************************
This demo, show via 128x64 LCD (GLCD 3 beta library) and Serial Monitor the value of the potenciometer between 9 numbers (0 to 8).
With a potenciometer and a button, you can move around a menu, and select the option that you want.
Hardware needed: - push button in digitalpin 12 - 128x64 LCD with glcd library or Serial Monitor - Potenciometer in analogPin 0
This code is in the public domain. Code by Hombrelobo, Timosoft Team. www.mundobocata.com */ //#include <glcd.h> // for LCD //#include "fonts/Arial14.h" // for LCD //#include "fonts/SystemFont5x7.h" // for LCD
int val = analogRead(0); int election;
void setup() { Serial.begin(9600); // GLCD.Init(NON_INVERTED); // for LCD // GLCD.SelectFont(System5x7); // for LCD // GLCD.ClearScreen(); // for LCD pinMode(digitalRead(12), INPUT); }
void loop() { int val = analogRead(0); val = map(val, 0, 1023, 0, 8); // Map an analog value to 9 numbers ( 0 to 8) Serial.println ((long)val); // GLCD.CursorTo(0,4); // for LCD // GLCD.Puts("Estate= position "); // for LCD // GLCD.PrintNumber(val); // for LCD // GLCD.CursorTo(0,6); // for LCD // GLCD.Puts("Last Option="); // for LCD // GLCD.PrintNumber(election); // for LCD if (digitalRead(12)==HIGH) { election=val; } else{ } }
|
|
|
|
|
6
|
Forum 2005-2010 (read only) / Español / Re: Piedra Papel Tijera
|
on: December 25, 2010, 02:59:51 am
|
En la pagina de la libreria te dice como conectarlo, porque al hacer la foto, realmente no se ve nada mas que una maraña de cables. Ten en cuenta que los pines del lcd se cuentan al REVES, es decir, segun miras el lcd, el de mas a la derecha es el numero 1, repito, el numero 1. Es un error muy común contar los pines desde el otro lado. Seguramente por eso no te funcione. A mi me pasaba lo mismo. Cualquier cosa dime y te ayudare con mucho gusto. Yo en concreto funciono con la librería GLCD3 Beta. Salud! How to setup the library for the 128x64 LCD module:
1. Please check the website first:
http://www.arduino.cc/playground/Code/GLCDks0108
2. Download the zip file :
http://www.arduino.cc/playground/uploads/Code/ks0108GLCD.zip
3. If you use arduino-0021, put the "ks0108" folder under arduino-0021\libraries\ somethings like "\arduino-0021\libraries\ks0108"
4. under the "ks0108" , there is a file named "ks0108_Panel.h" , you may need to change the following line:
From : #define EN_DELAY_VALUE 6 // this is the delay value that may need to be hand tuned for slow panels To : #define EN_DELAY_VALUE 8 // this is the delay value that may need to be hand tuned for slow panels
5. Then open the file : \arduino-0021\libraries\ks0108\examples\GLCDexample\GLCDexample.pde by arduino IDE, compile and upload the program to the arduino mega. You can test the arduino KIT now.
PS: There is a GLCD3 Beta library , so after you complete the above instruction and get the lcd working. It is a great fun to intall the GLCD3 library and other library (Time library for example) . The following link is to the GLCD3 beta library thread.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1279128237/0
|
|
|
|
|
8
|
Forum 2005-2010 (read only) / Español / Piedra Papel Tijera
|
on: December 20, 2010, 06:18:15 am
|
Os dejo mi primer proyecto en arduino, comentado para torpes porque al principio he necesitado escribir todo para volver a coger el hilo. No seáis muy crueles,hacia casi 16 años que no escribía código en serio. Para lcd de 128x64. #include <glcd.h> #include "fonts/Arial14.h" // proportional font #include "fonts/SystemFont5x7.h" // system font #include "bitmaps/jankenpon.h" // bitmap #include "bitmaps/piedra.h" // bitmap #include "bitmaps/papel.h" // bitmap #include "bitmaps/tijera.h" // bitmap #include "bitmaps/nada.h" // bitmap #include "bitmaps/win.h" // bitmap #include "bitmaps/lose.h" // bitmap
int jugador; int marcadorJugador = 0 ; //declaro marcadores int marcadorMaquina = 0 ;//declaro marcadores int maquina; //declaro decision de la maquina 0 1 o 2 que definire mas adelante int zumbador = 12; //declaro zumbador a la salida 12
void setup () { GLCD.Init(NON_INVERTED); // initialise the library GLCD.SelectFont(System5x7); // select fixed width system font
pinMode(zumbador, OUTPUT); //declaro el zumbador como salida GLCD.DrawBitmap(jankenpon, 0,0, BLACK); // pinta en pantalla el logo del jan ken pon delay(2000); GLCD.ClearScreen(); digitalWrite (zumbador,LOW);// apago el zumbador }
void loop(){ GLCD.CursorTo(0,0); GLCD.Puts("PLAYER="); GLCD.PrintNumber(marcadorJugador); GLCD.CursorTo(11,0); GLCD.Puts("ARDUINO="); GLCD.PrintNumber(marcadorMaquina);
if (marcadorJugador==3){ GLCD.ClearScreen(); GLCD.DrawBitmap(win, 0,0, BLACK); //ganaste! delay(1000); return; } else if (marcadorMaquina==3){ GLCD.ClearScreen(); GLCD.DrawBitmap(lose, 0,0, BLACK); // perdiste! delay(1000); return; } else{ maquina=random(0, 3); //numero aleatorio del 0 al 2 jugador=40; delay(1000); comienzoJuego(); delay(1000); deteccionBoton(); delay(1000); comprobarEstados(); delay(1000); } }
void comienzoJuego(){// comienza ciclo de 3 pitidos de la cancion y las palabras en la pantalla GLCD.CursorTo(0,7); // positon cursor GLCD.Puts(" "); //escribir en la pantalla "JAN" GLCD.DrawBitmap(nada, 10,10, BLACK); GLCD.DrawBitmap(nada, 70,10, BLACK); digitalWrite (zumbador,HIGH); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("JAN!"); //escribir en la pantalla "JAN" digitalWrite (zumbador,LOW);// apago el zumbador delay(1000);//espera segundos
digitalWrite (zumbador,HIGH); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("KEN!"); //escribir en la pantalla "KEN" digitalWrite (zumbador,LOW);// apago el zumbador delay(1000);//espera segundos
digitalWrite (zumbador,HIGH); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("PON!"); //escribir en la pantalla "PON" digitalWrite (zumbador,LOW);// apago el zumbador delay(1000);//espera segundos
GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("LET´S GO!"); //escribir en la pantalla "A JUGAR!!" delay(1000);//espera segundos }
void deteccionBoton(){ // comienza deteccion de entradas if (digitalRead(2)==HIGH) { jugador = 0; GLCD.DrawBitmap(piedra, 10,10, BLACK); // pinta en pantalla el logo del jan ken pon } else if (digitalRead(3)==HIGH) { jugador = 1; GLCD.DrawBitmap(papel, 10,10, BLACK); // pinta en pantalla el logo del jan ken pon } else if (digitalRead(4)==HIGH) { jugador = 2; GLCD.DrawBitmap(tijera, 10,10, BLACK); // pinta en pantalla el logo del jan ken pon } } void comprobarEstados (){ GLCD.CursorTo(0,7); // positon cursor GLCD.Puts(" "); //escribir en la pantalla "JAN" if (jugador==40){ GLCD.CursorTo(0,7); // positon cursor GLCD.Puts("PLEASE, PUSH A BUTTON"); // } else if (jugador==0 && maquina==0){ // si piedra es nulo y maquina GLCD.DrawBitmap(piedra, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("DRAW"); // imprime en pantalla "EMPATE!" } else if(jugador==0 && maquina==1){ GLCD.DrawBitmap(papel, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU LOSE"); // imprime en pantalla "PIERDES!" marcadorMaquina= marcadorMaquina + 1;//actualizo marcadores } else if(jugador==0 && maquina==2){ GLCD.DrawBitmap(tijera, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU WIN"); // imprime en pantalla "GANAS!" marcadorJugador= marcadorJugador + 1; //actualizo marcadores } else if(jugador==1 && maquina==0){ GLCD.DrawBitmap(piedra, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU WIN"); // imprime en pantalla "GANAS!" marcadorJugador= marcadorJugador + 1; //actualizo marcadores } else if(jugador==1 && maquina==1){ GLCD.DrawBitmap(papel, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("DRAW"); // imprime en pantalla "EMPATE!" } else if(jugador==1 && maquina==2){ GLCD.DrawBitmap(tijera, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU LOSE"); // imprime en pantalla "PIERDES!" marcadorMaquina= marcadorMaquina + 1;//actualizo marcadores } else if(jugador==2 && maquina==0){ GLCD.DrawBitmap(piedra, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU LOSE"); // imprime en pantalla "PIERDES!" marcadorMaquina= marcadorMaquina + 1;//actualizo marcadores } else if(jugador==2 && maquina==1){ GLCD.DrawBitmap(papel, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(7,7); // positon cursor GLCD.Puts("YOU WIN"); // imprime en pantalla "GANAS!" marcadorJugador= marcadorJugador + 1; //actualizo marcadores } else if(jugador==2 && maquina==2){ GLCD.DrawBitmap(tijera, 70,10, BLACK); // pinta en pantalla el logo del jan ken pon delay (500); GLCD.CursorTo(8,7); // positon cursor GLCD.Puts("DRAW"); // imprime en pantalla "EMPATE!" } }
Os dejo los archivos ".h" por si queréis compilarlo. http://rapidshare.com/files/438352101/jan_ken_pon_103.zip
|
|
|
|
|
9
|
Forum 2005-2010 (read only) / Español / Re: Ayuda con la extraccion de un sketch
|
on: December 03, 2010, 12:32:47 pm
|
segun me ha dicho el vendedor es la demo por defecto de GLCD3 pero todo seguido como el paso doble, no a tramos como aparece en los archivos de la demo. Esto es lo que me ha mandado: How to setup the library for the 128x64 LCD module: 1. Please check the website first: http://www.arduino.cc/playground/Code/GLCDks01082. Download the zip file : http://www.arduino.cc/playground/uploads/Code/ks0108GLCD.zip3. If you use arduino-0021, put the "ks0108" folder under arduino-0021\libraries\ somethings like "\arduino-0021\libraries\ks0108" 4. under the "ks0108" , there is a file named "ks0108_Panel.h" , you may need to change the following line: From : #define EN_DELAY_VALUE 6 // this is the delay value that may need to be hand tuned for slow panels To : #define EN_DELAY_VALUE 8 // this is the delay value that may need to be hand tuned for slow panels 5. Then open the file : \arduino-0021\libraries\ks0108\examples\GLCDexample\GLCDexample.pde by arduino IDE, compile and upload the program to the arduino mega. You can test the arduino KIT now. PS: There is a GLCD3 Beta library , so after you complete the above instruction and get the lcd working. It is a great fun to intall the GLCD3 library and other library (Time library for example) . The following link is to the GLCD3 beta library thread.
|
|
|
|
|
12
|
Forum 2005-2010 (read only) / Español / Ayuda con la extraccion de un sketch
|
on: December 03, 2010, 07:05:12 am
|
|
Hola, me acaba de llegar una placa mega con un lcd y la verdad me gustaría extraer el sketch de la demo del lcd para hacerle ingeniería inversa y aprender como han programado el lcd.
El problema es que he buscado en el foro y aunque otros lo han preguntado, no consigo extraer nada en claro.
¿me podeis echar un cable? uso mac.
gracias!
|
|
|
|
|