✅ SNAKE GAME con MATRIZ LED 8x8 || MINIJUEGO con ARDUINO || [Explicado paso a paso] FACIL

  Рет қаралды 37,524

Robot UNO

Robot UNO

4 жыл бұрын

▶CÓDIGO DE PROGRAMACIÓN + ESQUEMA DE CONEXIONES: www.robotuno.com/minijuego-co...
▶LISTA de MATERIALES:
🟣 Pack de servomotores: amzn.to/2KbTCnp
🟠 Motor paso a paso: amzn.to/36WMo0d
🟢 Placa Arduino: amzn.to/2Q9yYbd
🟣 Cables: amzn.to/2X7xwaP
📢 Mi kit de iniciación en ARDUINO: amzn.to/2QbOxPA
+++++++++++++++++++++++++++++
+++++++ REDES SOCIALES +++++++
+++++++++++++++++++++++++++++
✅Instagram: robotuno?u...
✅TikTok: / robot_uno
✅Pagina web: www.robotuno.com/
➜COMENTA que te ha parecido y dale a 👍
➜SUSCRIBETE para no perderte ningún vídeo

Пікірлер: 192
@RobotUNO
@RobotUNO 7 ай бұрын
👇Más Proyectos de Electronica y Arduino👇 www.robotuno.com/
@d.ialanbaetke6199
@d.ialanbaetke6199 Жыл бұрын
Buenísimo el vídeo súper entendible, lo voy a probar!! Podrías compartir la programación por favor 😊
@miguelinpinguin5332
@miguelinpinguin5332 2 жыл бұрын
Es flipante tu contenido tío, tenes una voz hermosa wapi
@enrique_dez500
@enrique_dez500 2 жыл бұрын
Muchísimas Graciaaas!
@adolfoarturomateo3234
@adolfoarturomateo3234 Жыл бұрын
Hola ... Es un gran proyecto y muy entretenido... Lo voy hacer para la escuela ... Me puedes compartir el código de favor ..🙏
@jhellenvaleriamunozsalinas394
@jhellenvaleriamunozsalinas394 9 ай бұрын
Hola, me encanto mucho tu video y quisiera hacerlo. Pero me gustaría ver uno paso a paso del juego pong❤
@carloscastrocastro6093
@carloscastrocastro6093 3 ай бұрын
Hola , saludos , gracias por compartir el proyecto , ¿se puede hacer con dos matrices led ?
@luznavia1098
@luznavia1098 2 жыл бұрын
Un saludo, me gustó mucho este proyecto, lo voy a hacer para mi proyecto de robótica, me puedes pasar la programación, la necesito muchísimo
@JorgeMartinez-ih5nx
@JorgeMartinez-ih5nx 3 жыл бұрын
hola, gran trabajo amigo una duda me podrias ayudar ya subi el codigo pero no muevo nada con el joystick
@robingilduran
@robingilduran Жыл бұрын
Hola, buen video... felicidades!!! Me regalarías el código de Arduino? Gracias
@imanoloropeza3520
@imanoloropeza3520 3 жыл бұрын
esta bueno tu video se podría hacer un video explicando el codigo
@RobotUNO
@RobotUNO 3 жыл бұрын
Si, a partir de ahora voy a explicar todos los codigos de programacion en los videos.
@wilyrodrigonavarroquispe1576
@wilyrodrigonavarroquispe1576 10 ай бұрын
Buen video mi hermano, me podría facilitar la programación?
@ricardoguardado5868
@ricardoguardado5868 Жыл бұрын
Hola es un gran proyecto voy a utilizarpara un trabajo de la UNI, puedes compartirme el código de favor
@josedanielbustamantegallar4188
@josedanielbustamantegallar4188 2 жыл бұрын
buenas noches cuando usted pueda podria pasarme los codigos de programacion para realizar dicho minijuego porfavor, muchas gracias
@jorgeherreromarcos5963
@jorgeherreromarcos5963 8 ай бұрын
Muy chulo!!! Puedes pasarme el código porfa???😁
@giovannard1535
@giovannard1535 2 жыл бұрын
Hola!, muy buen video pero tengo una duda, ¿Cómo conectaría mas matrices de led para hacerlo mas grande? ¿Habría cambios en el código?
@ciroferber
@ciroferber Жыл бұрын
bueno, primero que todo, mas matrices led = mayor pines por lo que necesitaras un arduino mega o mas grande, luego necesitaras una bateria mas grande al menos que este usando tu pc como fuente, y si... el codigo cambiaria
@christiancevallos
@christiancevallos 5 ай бұрын
Hola.. Suscrito desde ya.. Gracias por tu aporte.. Quiero implementarlo.. Me. Podrías ayudar con el código de programación por favor
@javierornelas7290
@javierornelas7290 2 жыл бұрын
Me podrías pasar el código porfavor... Exelente proyecto, mi hijo está iniciando gracias ...
@sandovallarajeseniadelrosa700
@sandovallarajeseniadelrosa700 2 жыл бұрын
Hola ya estoy suscrita, me puedes pasar el código de programación.?
@carlospalou7461
@carlospalou7461 3 жыл бұрын
Buenas, podrías pasar la programación para ArduinoBlocks? Gracias!
@danielfelipecarvajalsaenz2599
@danielfelipecarvajalsaenz2599 9 ай бұрын
Hola Muy buen proyecto!! podrías hacerme el favor de pasarme la programación
@vicoldayanafonsecaescarrag1116
@vicoldayanafonsecaescarrag1116 Жыл бұрын
Holaaaaa, encontré lo que buscaba, m podrías ayudar con el código? :')
@brandomorgan4617
@brandomorgan4617 3 жыл бұрын
Disculpa... Tendrás un mini juegos utilizando al arduino y el visual studios ?
@RobotUNO
@RobotUNO 3 жыл бұрын
No, lo siento, nunca he utilizado ese programa : (
@alexteutla4325
@alexteutla4325 3 жыл бұрын
Recomiendo q lo agan con 3.3voltios si lo ponen en 5 la placa se calienta y no enciende
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchas gracias por el consejo!
@federicovega367
@federicovega367 6 ай бұрын
Como hago eso @alexteutla4325
@brunoluis1070
@brunoluis1070 3 жыл бұрын
bro una consulta.... esto se puede hacer sin el protoboard este proyecto? buen vídeo sigue así nuevo sub.
@RobotUNO
@RobotUNO 3 жыл бұрын
por supuesto que se puede! en este proyecto solo se utiliza para hacer las conexiones del buzzer y para alimentar los circuitos. Un saludo Bruno y bienvenido al canal!
@brunoluis1070
@brunoluis1070 3 жыл бұрын
@@RobotUNO ok muchas gracias
@urielsanchez4478
@urielsanchez4478 2 жыл бұрын
@@RobotUNO tengo un buzer pero con un circuito integrado , funciona igual ?????? , a y el pinpong me sirvio
@IngAndrezael
@IngAndrezael 3 жыл бұрын
Robot UNO, en qué software realizaste el diseño de montaje... Gracias!
@dulzuravallecaucana8628
@dulzuravallecaucana8628 Жыл бұрын
arduino ide
@jordansantiagocruzarcinieg9812
@jordansantiagocruzarcinieg9812 3 жыл бұрын
Buenas noches cómo me puedo comunicar con la persona que realizó el proyecto con arduino gracias 👌👌
@raulcruzmorales5993
@raulcruzmorales5993 Ай бұрын
También sirve si es una matriz de 8x32
@65-gabrielbenitez79
@65-gabrielbenitez79 3 жыл бұрын
Hola, tuve un problema, con ayuda de los comentarios logré que funcione conectado a una PC de escritorio. Lo probé con una notebook y no funciona. Es como si el juego está pero sin los leds prendidos. Que puede ser?
@user-vn7hw6st1i
@user-vn7hw6st1i Жыл бұрын
Hola, me podrías pasar el código de programación para poder subirlo a mi proyecto? gracias.
@eliashenao9287
@eliashenao9287 3 жыл бұрын
Agradeciendo por video muy genial. Un favor me puedes enviar el código gracias. 👍✌️
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchisimas gracias Elias, aqui tienes el codigo!!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@celiajuarezangeles8825
@celiajuarezangeles8825 2 жыл бұрын
@@RobotUNO El texto que copies aparecerá automáticamente aquí
@joseguadalupesanchezalvara1394
@joseguadalupesanchezalvara1394 2 жыл бұрын
Cuanto cuesta el paquete completo para realizarlo?
@carmat3885
@carmat3885 5 ай бұрын
Muchas gracias por el video me puedes pasar el código. Saludos
@josuelopez8731
@josuelopez8731 3 жыл бұрын
Amigo cuando subo el codigo me da pero una parte de las Led me encienden pero de ahi no me funciona?
@thedarkmagician4264
@thedarkmagician4264 3 жыл бұрын
Hola, muy buen tutorial. Me encantó. Me pasarías el código xfa
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchas gracias!! Aqui tienes el codigo!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@amaartineez
@amaartineez 3 жыл бұрын
@@RobotUNO brother esta programación no se deja subir me dice que hay un error
@federicovega367
@federicovega367 6 ай бұрын
A mi me deja subirla
@federicovega367
@federicovega367 6 ай бұрын
Pero no hace nada
@jordansantiagocruzarcinieg9812
@jordansantiagocruzarcinieg9812 3 жыл бұрын
Robot uno como me puedo comunicar con usted personalmente gracias 👌🙏
@Tr-uc8dz
@Tr-uc8dz 3 жыл бұрын
Mejor canal de arduino, me pasas el código por favor?
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchisimas gracias
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@jharllytmartinez2128
@jharllytmartinez2128 3 жыл бұрын
Robot UNO abastá
@mauriciovazquez7976
@mauriciovazquez7976 3 жыл бұрын
La programación sería la misma si la haces sin la protoboar
@janunlejayimtobim7072
@janunlejayimtobim7072 2 жыл бұрын
HOLA.. estoy siguiendo tu tutorial para hacer reproducir el juego de gusanito... pero me encuentro que con un obstaculo ya que el probrla no me corre y me dice que el código no esta en la biblioteca... podrias ayudarme por favor es tu trabajo escolar... y necesito una buena nota ya que es un trabajo de autoaprendizaje ... GRADEZCO TU COLABORACION... atentamente una seguidora
@denisvallejosfelipe637
@denisvallejosfelipe637 3 жыл бұрын
buem proyecto me encanto me pasarias el el codigo porfa
@anderojeda483
@anderojeda483 Жыл бұрын
hola buen video, podrias pasarme la programacion de este minijuego?
@amaartineez
@amaartineez 3 жыл бұрын
hola brother excelente proyecto tienes el plano de construcción es que va un poco rapido y me e perdido
@RobotUNO
@RobotUNO 3 жыл бұрын
No se como hacerlos :( lo siento mucho
@amaartineez
@amaartineez 3 жыл бұрын
Robot UNO si quiere le ayudo pero si sería bueno que explicaras como se conecta brother por que me aveces se genera confucion
@RobotUNO
@RobotUNO 3 жыл бұрын
Vale, lo tendré en cuenta para futuros videos, muchas gracias!
@lancontrols6051
@lancontrols6051 2 жыл бұрын
No me funcionaaaaaaa!!! no me prende la matriz ni siquiera
@ProBar-ix2yk
@ProBar-ix2yk 2 ай бұрын
😂😂😂
@julianalias81
@julianalias81 3 жыл бұрын
Muy buen proyecto Me pasas el código?
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchas gracias Julian! en el comentario de abajo te dejo el codigo. Un saludo!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@pvz2058
@pvz2058 3 жыл бұрын
Mándame el código, por cierto me encanto el vídeo bro
@RobotUNO
@RobotUNO 3 жыл бұрын
Muchas gracias Gabriel! Aqui tienes el codigo!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@sergioandrescadena4277
@sergioandrescadena4277 2 жыл бұрын
Me gusto el proyecto me puedes enviar el código me
@luisfernandolazcanovillanu9982
@luisfernandolazcanovillanu9982 2 жыл бұрын
Como puedo integrar esa programación a un 16x16?
@fennikk2569
@fennikk2569 Жыл бұрын
cuando pongo un cable en el huequito de 5V de la tarjeta o en el GND y lo conecto al protoboard, mi tarjeta de arduino se apaga y no me deja subirle el codigo, que hago?
@isaibarreto9360
@isaibarreto9360 2 жыл бұрын
bro tienes el diagrama esquemático por favor
@samuelcastano6044
@samuelcastano6044 3 жыл бұрын
El proyecto se podria hacer sin el cosito verde de la matriz?
@samuelcastano6044
@samuelcastano6044 3 жыл бұрын
Olvidalo aun asi me acabo de dar cuenta de q mi matriz es diferente
@g.9843
@g.9843 2 жыл бұрын
Pero no se puede??
@luisguillermocrosspastrana4269
@luisguillermocrosspastrana4269 6 ай бұрын
Si ers eso, es la primera que dale LedControl
@franciscoquevedobetbeder4909
@franciscoquevedobetbeder4909 Жыл бұрын
me das el codigo de programacion porfa estoy suscrito
@bassbnst4077
@bassbnst4077 4 ай бұрын
Hola me interesa saber el código de programación me lo podrías pasar ?? estoy suscrito
@franciscofalcon1380
@franciscofalcon1380 2 жыл бұрын
como hiciste el montaje en la web?
@RobotUNO
@RobotUNO 2 жыл бұрын
Con fritzing
@marialeliaguzmanramirez8046
@marialeliaguzmanramirez8046 Жыл бұрын
EXCELENTES VIDEOS, LO FELICITO!! UNA PREGUNTA YA SE CONECTO TODO IGUAL Y EL CÓDIGO QUE NOS HIZO FAVOR DE PROPORCIONAR TAMBIÉN TODO IGUAL PERO O SE ESCUCHA COMO TERMINA EL JUEGO AL CONECTAR EL ARDUINO Y LA PANTALLA PRENDE COMPLETA POR UN INSTANTE O DE PLANO NO FUNCIONA, YA CAMBIAMOS EL JOYSTICK Y LA PANTALLA TODO NUEVO Y NADA, ME PODRÍA ILUSTRAR AL RESPECTO, POR FAVOR, GRACIAS
@ProfeRafaSTEM
@ProfeRafaSTEM 9 ай бұрын
Oye, yo también estaba igual que tu, pero ya me quedo. Hay algunos detalles que tienes que cambiar, me costo un poquito de trabajo, pero si funciona. Si gustas te puedo compartir la información
@marialeliaguzmanramirez8046
@marialeliaguzmanramirez8046 9 ай бұрын
@@ProfeRafaSTEM Buenas noches! Si xfa, gracias
@ProfeRafaSTEM
@ProfeRafaSTEM 9 ай бұрын
Pues mira, si observas los pines del diagrama no coinciden con los números en el código que esta en su portal. Por ejemplo en el diagrama los pines que se especifican son 7, 10, 9 y 11, pero en el código son: 8, 10, 11 y 12. Los pines análogos están bien. Y otro número que debes cambiar es en la línea 19; la que dice LedControl 1c = LedControl (DIN, CS, CLK, 0) Si observas en el código original aparece un 1, yo lo cambie por un cero y eso es todo. Espero y te sirva mi información. ¡Saludos!!!
@federicovega367
@federicovega367 6 ай бұрын
​@@ProfeRafaSTEM lo del numero 1 lo encontre pero el resto no lo entiendo que tengo que cambiar?
@federicovega367
@federicovega367 6 ай бұрын
Si me puedes responder lo agradeceria
@mtra.loredecena3680
@mtra.loredecena3680 2 жыл бұрын
Buen día, me puede pasar el código por favor.
@DavidPalmerin-sp3jt
@DavidPalmerin-sp3jt Жыл бұрын
Puedes pasar la programación por favor 😁😁😁😁
@OscarRH3
@OscarRH3 Жыл бұрын
revise las conexiones el voltaje y no me funciono, parece que si carga el codigo pero se quedan los leds del display apagados y no ocurre nada, ni siquiera el buzzer suena
@luisguillermocrosspastrana4269
@luisguillermocrosspastrana4269 6 ай бұрын
Compa buenas noches, creo que la falla que me sale es por la librería
@denisvallejosfelipe637
@denisvallejosfelipe637 3 жыл бұрын
bro ay un herror en el codigo de programacion
@miguelangelaguileravelazqu1893
@miguelangelaguileravelazqu1893 Жыл бұрын
Hola quisiera el Código oara realizarlo saludos
@adrianpando6158
@adrianpando6158 3 жыл бұрын
No se me prenden todos los leds del 8x8 ya voy comprando dos de los mismos y no funcionan
@RobotUNO
@RobotUNO 3 жыл бұрын
Quizas sea otro modelo y alguna conexion sea diferente.
@user-mf1du9qs6i
@user-mf1du9qs6i 2 ай бұрын
Me podrias pasar el código de programación porfavor
@cirouribe6976
@cirouribe6976 Жыл бұрын
Hola me pasas el codigo de programacion por favor
@KarenRuiz-hk4zj
@KarenRuiz-hk4zj Ай бұрын
Hola , q tal me podrá pasar la programación porfavor 🥺🥺
@saidvalerav2048
@saidvalerav2048 3 жыл бұрын
hola me das un consejo para mejorar mi canal
@RobotUNO
@RobotUNO 3 жыл бұрын
Hazlo por que te gusta, no por el dinero ni nada. KZbin ya no es como antes
@saidvalerav2048
@saidvalerav2048 3 жыл бұрын
@@RobotUNO gracias este es el mejor canal
@ivanandradezambrano7262
@ivanandradezambrano7262 3 жыл бұрын
Podrías pasarme el código de programación pero yo solo tengo el driver máxim sin modulo
@RobotUNO
@RobotUNO 3 жыл бұрын
Claro! aqui lo tienes!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@DAER-wt5tm
@DAER-wt5tm 3 жыл бұрын
Hola bro, una pregunta, el código no me lo acepta. Por cierto nuevo suscripitor, ;)
@RobotUNO
@RobotUNO 3 жыл бұрын
Cual es el error?? has instalado la libreria?
@DAER-wt5tm
@DAER-wt5tm 3 жыл бұрын
@@RobotUNO si ya la instale, es la parte, #include "LedControl.h", me carga error
@DAER-wt5tm
@DAER-wt5tm 3 жыл бұрын
disculpa bro, fue mi error, pero gracias y buen video
@urielperezgomez3112
@urielperezgomez3112 3 жыл бұрын
El mio si es la librería ¿Puedes ayudarme en eso?
@nombreapellido2231
@nombreapellido2231 2 жыл бұрын
Cómo se llama la cosita que hace ruido?
@sebasarias900
@sebasarias900 2 жыл бұрын
Alguien me ayuda!! Me dice que el "LedControl.h" no existe. Que hago??
@ingridortiz4185
@ingridortiz4185 2 жыл бұрын
Podrías pasar el código...
@RogyerVargas
@RogyerVargas 8 күн бұрын
Nesecito la programación
@agustina.g7031
@agustina.g7031 3 жыл бұрын
el diagrama de conexión esta mal
@RobotUNO
@RobotUNO 3 жыл бұрын
Cual es el error?
@annettaa2
@annettaa2 3 жыл бұрын
@@RobotUNO Yo te lo he indicado en varios comentarios si lo revisas a lo mejor se puede editar y añadir los arreglos.
@luisguillermocrosspastrana4269
@luisguillermocrosspastrana4269 6 ай бұрын
Cómo se llama la librería?
@borjaaltamiraareizaga6532
@borjaaltamiraareizaga6532 3 жыл бұрын
Hola, me gusta mucho! Podrías enviarme el código de programación? Muchas gracias!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@borjaaltamiraareizaga6532
@borjaaltamiraareizaga6532 3 жыл бұрын
@@RobotUNO muchas gracias!
@soymaxmilla
@soymaxmilla 3 жыл бұрын
Me podrías dar la programación ?, Sirve igual que con una matriz led de 16x16
@RobotUNO
@RobotUNO 3 жыл бұрын
Habria que cambiar algunos parametros en la programacion. Aqui tienes el codigo!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@soymaxmilla
@soymaxmilla 3 жыл бұрын
@@RobotUNO Cual seria la programación para que la comida de la serpiente salga de otro color ??
@RobotUNO
@RobotUNO 3 жыл бұрын
Estas matrices estan compuestas por leds de color rojo, asi que es algo imposible :(
@lost_kazzy7953
@lost_kazzy7953 11 ай бұрын
Hola puedes pasarme el código de programación
@jorgeroberto1733
@jorgeroberto1733 Жыл бұрын
Hola Master pasame el codigo desde ya gtacias
@rubimurillo4901
@rubimurillo4901 2 жыл бұрын
Tengo Arduino uno y el programa me arroja el error : ^~~~~~~~~~~~~~ compilation terminated. exit status 1 LedControl.h: No such file or directory
@ElKaijus31
@ElKaijus31 2 жыл бұрын
eso es porque tienes que descargar una librería que te permita controlar la matriz la cual se llama "LedControl.h" y la podes descargar desde la pág. oficial de Arduino, y para la instalación de la librería se debe hacer lo siguiente: debes abrir el programa de Arduino 2do te vas al apartado superior donde dice "Programa" luego le clickas donde dice "incluir librería" desde ahí tocas la opción "Añadir Biblioteca .zip …" eso te va a abrir una pestaña en la que podrás seleccionar e instalar la librería que se encuentra en el zip que descargaste anteriormente de la pág. oficial de Arduino.
@elbarril447
@elbarril447 3 жыл бұрын
bro tengo un problema q el punto se mueve solo sin q yo toque nda (como en modo automatico), tienes alguna solucion?
@RobotUNO
@RobotUNO 3 жыл бұрын
No se a que se puede deber. Solo puedo decirte que compruebes si el montaje esta bien hecho. Te paso otra vez el codigo de programacion por si fuese eso... Un saludo.
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@pdfsbanda8300
@pdfsbanda8300 2 жыл бұрын
Como lo solucionaste amigo? Tengo el mismo problema
@elbarril447
@elbarril447 2 жыл бұрын
@@pdfsbanda8300 resulto q uno de los pines del stick estaba da;ado, lo solucione conectandolo de una forma distinta, aunq ahora mismo noo recuerdo como, espero te haya servido
@pdfsbanda8300
@pdfsbanda8300 2 жыл бұрын
@@elbarril447 pero usaste el mismo codigo de programacion? No le cambiaste nada? Gracias amigo
@claudiamerlos1817
@claudiamerlos1817 2 жыл бұрын
Hola me podrías dar el código?
@g.9843
@g.9843 2 жыл бұрын
hola, buen video... pero nunca funciona la matriz de led, realice la conexion, coloque el codigo. descargue la libreria LedControl. se escuchaba el parlante cuando comia(lo hacia sin ver y cuando moria que es un sonido prolongado) y despues de eso recien se enciende todas las luces led de la matriz y se reeinicia apagandolas todas... espero que puedas respnder...gracias.
@urielsanchez4478
@urielsanchez4478 2 жыл бұрын
Hola como lei por ahi dicen porque 5 voltios es mucho, intentalo con el 3.3 voltios
@g.9843
@g.9843 2 жыл бұрын
@@urielsanchez4478 Gracias.. lo intentare.
@urielsanchez4478
@urielsanchez4478 2 жыл бұрын
@@g.9843 de nada
@urielsanchez4478
@urielsanchez4478 2 жыл бұрын
@@g.9843 te finciono??
@urielsanchez4478
@urielsanchez4478 2 жыл бұрын
Funciono*
@RogyerVargas
@RogyerVargas 8 күн бұрын
La programación porfaaaaa
@weedsoldier2
@weedsoldier2 7 ай бұрын
Bueno y el código?
@RogyerVargas
@RogyerVargas 8 күн бұрын
Por fvaro
@user-ku2nn6kv4q
@user-ku2nn6kv4q Жыл бұрын
hola el codigo porfavor
@stivensanchez7850
@stivensanchez7850 7 ай бұрын
alguien me ayuda el código le da error ayúdame
@user-ev2hm4wl7m
@user-ev2hm4wl7m 8 ай бұрын
Necesito el código porff
@mari0_gomezz
@mari0_gomezz 3 жыл бұрын
Hola, no me funciona el código.
@RobotUNO
@RobotUNO 3 жыл бұрын
Has instalado las librerias correspondientes? quizas sea eso
@revillaaldaveracristian9451
@revillaaldaveracristian9451 3 жыл бұрын
Que librería es?
@annettaa2
@annettaa2 3 жыл бұрын
Hola, a mi tampoco me funcionaba con las librerias puestas y he encontrado errores en el dibujo hay cables que no estan conectados en el sitio donde los conecta en el directo VCC siempre va al 5V y GND con GND después los pines del cuadro de leds tmb son diferentes en el diagrama El DIN va al 12, el CS va al 10 y el CLK va al 11. Revisa eso y te funcionara parte de ir al apartado gestionar librerias y buscar la de Ledcontrol y descargarla
@mari0_gomezz
@mari0_gomezz 3 жыл бұрын
@@annettaa2 Vale, muchísimas gracias
@GabrielSbro
@GabrielSbro 5 ай бұрын
Código?
@eduardocorchs8904
@eduardocorchs8904 3 жыл бұрын
me podrias pasar la libreria
@RobotUNO
@RobotUNO 3 жыл бұрын
Aqui tienes el codigo Eduardo!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@RobotUNO
@RobotUNO 3 жыл бұрын
La libreria ledcontrol.h la puedes encontrar en el propio programa de arduino. Un saludo,.
@mauricioordonezcarvajal5836
@mauricioordonezcarvajal5836 3 жыл бұрын
@@RobotUNO hice todo bro , pero no enciende el matrix cuando saco los cablecitos del arduino DIN,CS,CLIK, SE ENCIENDE TODA LA PANTALLA , CUAL PUEDE SER MI ERROR GRACIAS
@jackmendeztesucun6228
@jackmendeztesucun6228 Жыл бұрын
Necesito el código
@jhohanduarte8919
@jhohanduarte8919 3 жыл бұрын
Mándame la programación
@RobotUNO
@RobotUNO 3 жыл бұрын
Por supuesto! Un saludo Jhohan
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@1MegamaX200
@1MegamaX200 2 жыл бұрын
Pásame la progamacion
@user-np3gg8um4x
@user-np3gg8um4x 10 ай бұрын
Pasa el código
@EstebanQuintero-xi6jj
@EstebanQuintero-xi6jj 9 ай бұрын
Esta en la descripción
@desticgamer5947
@desticgamer5947 3 жыл бұрын
No me funciono el código
@RobotUNO
@RobotUNO 3 жыл бұрын
Cual de todos?? tienes instaladas las librerias?
@desticgamer5947
@desticgamer5947 3 жыл бұрын
@@RobotUNO tengo instalada el programa meter el código pero no me va el código
@desticgamer5947
@desticgamer5947 3 жыл бұрын
@@RobotUNO me interesa mucho tu proyecto y la verdad no se si abra un forma de comunicarse con Tigo
@RobotUNO
@RobotUNO 3 жыл бұрын
Puedes hablarme por correo electronico si quieres "manualidadesyarmas@gmail.com"
@RobotUNO
@RobotUNO 3 жыл бұрын
Has instalado la libreria "LedControl.h"?? Se hace desde la aplicacion de arduino IDE
@alexmoreyt8930
@alexmoreyt8930 3 жыл бұрын
me ouedes pasar el codigo?
@RobotUNO
@RobotUNO 3 жыл бұрын
CLARO!!! aqui lo tienes!
@RobotUNO
@RobotUNO 3 жыл бұрын
//Canal de KZbin -> RobotUNO //Juego snake en pantalla led 8x8 #include "LedControl.h" //pins const int SW_pin = 2; const int X_pin = 0; const int Y_pin = 1; const int DIN = 12; const int CS = 11; const int CLK = 10; const int BUZZER = 8; //variables const int screenWidth = 8; const int screenHeight = 8; int snakeX, snakeY, foodX, foodY, score = 0, snakeSize = 1; char direction; int tailX[100], tailY[100]; bool isGameOver = false; LedControl lc = LedControl(DIN, CS, CLK, 1); void setup() { setupPins(); setupLedBoard(); setupSnakePosition(); setupFoodPosition(); } void setupSnakePosition() { snakeX = 4; snakeY = 4; } void setupFoodPosition() { foodX = rand() % screenWidth; foodY = rand() % screenHeight; } void setupLedBoard() { lc.shutdown(0, false); lc.setIntensity(0, 1); lc.clearDisplay(0); } void setupPins() { pinMode(SW_pin, INPUT); digitalWrite(SW_pin, HIGH); } void loop() { if (isGameOver) { playGameOverSong(); showGameOverScreen(); } else { startGame(); } } void playGameOverSong() { tone(BUZZER, 1000, 1000); delay(100); tone(BUZZER, 2000, 1000); delay(100); tone(BUZZER, 3000, 1000); delay(100); tone(BUZZER, 4000, 1000); delay(100); tone(BUZZER, 5000, 2000); } void playFoodEatenSong() { tone(BUZZER, 500, 100); } void startGame() { manageGameOver(); setJoystickDirection(); changeSnakeDirection(); manageSnakeOutOfBounds(); manageEatenFood(); manageSnakeTailCoordinates(); drawSnake(); delay(300); } void manageGameOver() { for (int i = 1; i < snakeSize; i++) { if (tailX[i] == snakeX && tailY[i] == snakeY) { isGameOver = true; } } } void manageSnakeOutOfBounds() { if (snakeX >= screenWidth) { snakeX = 0; } else if (snakeX < 0) { snakeX = screenWidth - 1; } if (snakeY >= screenHeight) { snakeY = 0; } else if (snakeY < 0) { snakeY = screenHeight - 1; } } void manageSnakeTailCoordinates() { int previousX, previousY, prevX, prevY; previousX = tailX[0]; previousY = tailY[0]; tailX[0] = snakeX; tailY[0] = snakeY; for (int i = 1; i < snakeSize; i++) { prevX = tailX[i]; prevY = tailY[i]; tailX[i] = previousX; tailY[i] = previousY; previousX = prevX; previousY = prevY; } } void manageEatenFood() { if (snakeX == foodX && snakeY == foodY) { playFoodEatenSong(); score++; snakeSize++; setupFoodPosition(); } } void setJoystickDirection() { if (analogRead(X_pin) > 1000) { direction = 'u'; } else if (analogRead(X_pin) < 100) { direction = 'd'; } else if (analogRead(Y_pin) > 1000) { direction = 'l'; } else if (analogRead(Y_pin) < 100) { direction = 'r'; } } void changeSnakeDirection() { switch (direction) { case 'l': snakeX--; break; case 'r': snakeX++; break; case 'u': snakeY--; break; case 'd': snakeY++; break; } } void showGameOverScreen() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { showLed(j, i); delay(50); } } resetVariables(); } void resetVariables() { setupSnakePosition(); setupFoodPosition(); direction = ' '; isGameOver = false; score = 0; snakeSize = 1; } void showLed(int row, int column) { lc.setLed(0, row, column, true); } void hideLed(int row, int column) { lc.setLed(0, row, column, false); } void drawSnake() { for (int i = 0; i < screenHeight; i++) { for (int j = 0; j < screenWidth; j++) { if (i == snakeY && j == snakeX) { showLed(snakeX, snakeY); } else if (i == foodY && j == foodX) { showLed(foodX, foodY); } else { bool isShown = false; for (int k = 0; k < snakeSize; k++) { if (tailX[k] == j && tailY[k] == i) { showLed(j, i); isShown = true; } } if (!isShown) { hideLed(j, i); } } } } }
@alexmoreyt8930
@alexmoreyt8930 3 жыл бұрын
@@RobotUNO muchas graicas
@alexmoreyt8930
@alexmoreyt8930 3 жыл бұрын
@@RobotUNO tengo una duda,ami no me sale ""LedControl.h" como le puedo hacer?
@RobotUNO
@RobotUNO 3 жыл бұрын
tienes que instalarte la libreria
@XSETAyrinval
@XSETAyrinval 8 ай бұрын
No sirve tu chingadera
@albertosgaona2682
@albertosgaona2682 4 күн бұрын
Hola, buena noche amigo, ya suscribi, puedesandarme el codigo de favor.❤😊
@Vinland-lu8cd
@Vinland-lu8cd Жыл бұрын
Buenas, podrías pasar la programación para ArduinoBlocks? Gracias!
Como Utilizar el Módulo Matriz Led Max7219 con Arduino
14:38
ElectronicSpot
Рет қаралды 15 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 1,6 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 51 МЛН
Arduino 8x8 LED Matrix Tutorial without any Drivers
17:10
ELEXHUB
Рет қаралды 5 М.
✔️ Arduino UNO desde Cero - Control de Matriz Leds 8x8
8:19
Ing. René Domínguez
Рет қаралды 97 М.
How To Make Arduino Bluetooth Controlled Car - At Home
8:20
Crazy Think
Рет қаралды 283 М.
How to Build a 3D Printed Robot Arm Tutorial (Arduino Based) - Part Two
10:12
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 364 М.
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 5 МЛН
После ввода кода - протирайте панель
0:18
Up Your Brains
Рет қаралды 1,2 МЛН
Hisense Official Flagship Store Hisense is the champion What is going on?
0:11
Special Effects Funny 44
Рет қаралды 3,1 МЛН
Todos os modelos de smartphone
0:20
Spider Slack
Рет қаралды 7 МЛН
Samsung Galaxy Unpacked July 2024: Official Replay
1:8:53
Samsung
Рет қаралды 23 МЛН