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

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024
  • ▶CÓDIGO DE PROGRAMACIÓN + ESQUEMA DE CONEXIONES: www.robotuno.c...
    ▶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: www.instagram....
    ✅TikTok: / robot_uno
    ✅Pagina web: www.robotuno.com/
    ➜COMENTA que te ha parecido y dale a 👍
    ➜SUSCRIBETE para no perderte ningún vídeo

Комментарии • 197

  • @RobotUNO
    @RobotUNO  9 месяцев назад +2

    👇Más Proyectos de Electronica y Arduino👇
    www.robotuno.com/

    • @denilsonizaguirre8750
      @denilsonizaguirre8750 Месяц назад

      Hola amigo, necesito el codigo de programacion, ya que estoy haciendo tu ejemplo para un proyecto de la Universidad

  • @d.ialanbaetke6199
    @d.ialanbaetke6199 Год назад +2

    Buenísimo el vídeo súper entendible, lo voy a probar!! Podrías compartir la programación por favor 😊

  • @giovannard1535
    @giovannard1535 2 года назад +5

    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

  • @adolfoarturomateo3234
    @adolfoarturomateo3234 Год назад +2

    Hola ... Es un gran proyecto y muy entretenido... Lo voy hacer para la escuela ... Me puedes compartir el código de favor ..🙏

  • @JorgeMartinez-ih5nx
    @JorgeMartinez-ih5nx 3 года назад +3

    hola, gran trabajo amigo una duda me podrias ayudar ya subi el codigo pero no muevo nada con el joystick

  • @carloscastrocastro6093
    @carloscastrocastro6093 5 месяцев назад

    Hola , saludos , gracias por compartir el proyecto , ¿se puede hacer con dos matrices led ?

  • @miguelinpinguin5332
    @miguelinpinguin5332 2 года назад

    Es flipante tu contenido tío, tenes una voz hermosa wapi

  • @jhellenvaleriamunozsalinas394
    @jhellenvaleriamunozsalinas394 10 месяцев назад

    Hola, me encanto mucho tu video y quisiera hacerlo. Pero me gustaría ver uno paso a paso del juego pong❤

  • @robingilduran
    @robingilduran Год назад +2

    Hola, buen video... felicidades!!! Me regalarías el código de Arduino? Gracias

  • @JESUSMARIAARRIETALOPEZ-w9k
    @JESUSMARIAARRIETALOPEZ-w9k 4 дня назад

    Puede tener la pantalla LED mas grande ?

  • @alexteutla4325
    @alexteutla4325 3 года назад +6

    Recomiendo q lo agan con 3.3voltios si lo ponen en 5 la placa se calienta y no enciende

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Muchas gracias por el consejo!

    • @federicovega367
      @federicovega367 8 месяцев назад

      Como hago eso @alexteutla4325

  • @luznavia1098
    @luznavia1098 2 года назад +1

    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

  • @janunlejayimtobim7072
    @janunlejayimtobim7072 2 года назад +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

  • @josedanielbustamantegallar4188
    @josedanielbustamantegallar4188 2 года назад +3

    buenas noches cuando usted pueda podria pasarme los codigos de programacion para realizar dicho minijuego porfavor, muchas gracias

  • @raulcruzmorales5993
    @raulcruzmorales5993 3 месяца назад

    También sirve si es una matriz de 8x32

  • @samuelcastano6044
    @samuelcastano6044 3 года назад +3

    El proyecto se podria hacer sin el cosito verde de la matriz?

    • @samuelcastano6044
      @samuelcastano6044 3 года назад +1

      Olvidalo aun asi me acabo de dar cuenta de q mi matriz es diferente

    • @g.9843
      @g.9843 2 года назад

      Pero no se puede??

  • @thedarkmagician4264
    @thedarkmagician4264 4 года назад +5

    Hola, muy buen tutorial. Me encantó. Me pasarías el código xfa

    • @RobotUNO
      @RobotUNO  4 года назад +1

      Muchas gracias!! Aqui tienes el codigo!

    • @RobotUNO
      @RobotUNO  4 года назад +7

      //Canal de RUclips -> 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 года назад +1

      @@RobotUNO brother esta programación no se deja subir me dice que hay un error

    • @federicovega367
      @federicovega367 8 месяцев назад

      A mi me deja subirla

    • @federicovega367
      @federicovega367 8 месяцев назад

      Pero no hace nada

  • @user-vn7hw6st1i
    @user-vn7hw6st1i Год назад +1

    Hola, me podrías pasar el código de programación para poder subirlo a mi proyecto? gracias.

  • @denilsonizaguirre8750
    @denilsonizaguirre8750 Месяц назад

    Hola amigo, necesito el codigo de programacion, ya que estoy haciendo tu ejemplo para un proyecto de la Universidad, me lo pasas porfa?

  • @enrique_dez500
    @enrique_dez500 2 года назад

    Muchísimas Graciaaas!

  • @franciscoquevedobetbeder4909
    @franciscoquevedobetbeder4909 Год назад +1

    me das el codigo de programacion porfa estoy suscrito

  • @christiancevallos
    @christiancevallos 7 месяцев назад

    Hola.. Suscrito desde ya.. Gracias por tu aporte.. Quiero implementarlo.. Me. Podrías ayudar con el código de programación por favor

  • @brunoluis1070
    @brunoluis1070 4 года назад +3

    bro una consulta.... esto se puede hacer sin el protoboard este proyecto?
    buen vídeo sigue así nuevo sub.

    • @RobotUNO
      @RobotUNO  4 года назад +1

      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 4 года назад

      @@RobotUNO ok muchas gracias

    • @urielsanchez4478
      @urielsanchez4478 2 года назад

      @@RobotUNO tengo un buzer pero con un circuito integrado , funciona igual ?????? , a y el pinpong me sirvio

  • @brandomorgan4617
    @brandomorgan4617 3 года назад +1

    Disculpa...
    Tendrás un mini juegos utilizando al arduino y el visual studios ?

    • @RobotUNO
      @RobotUNO  3 года назад +1

      No, lo siento, nunca he utilizado ese programa : (

  • @ricardoguardado5868
    @ricardoguardado5868 Год назад

    Hola es un gran proyecto voy a utilizarpara un trabajo de la UNI, puedes compartirme el código de favor

  • @65-gabrielbenitez79
    @65-gabrielbenitez79 3 года назад +1

    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?

  • @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 Год назад

    Buen video mi hermano, me podría facilitar la programación?

  • @lancontrols6051
    @lancontrols6051 2 года назад +5

    No me funcionaaaaaaa!!! no me prende la matriz ni siquiera

  • @danielfelipecarvajalsaenz2599
    @danielfelipecarvajalsaenz2599 10 месяцев назад

    Hola
    Muy buen proyecto!! podrías hacerme el favor de pasarme la programación

  • @marialeliaguzmanramirez8046
    @marialeliaguzmanramirez8046 Год назад +1

    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 11 месяцев назад +1

      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 11 месяцев назад

      @@ProfeRafaSTEM Buenas noches! Si xfa, gracias

    • @ProfeRafaSTEM
      @ProfeRafaSTEM 11 месяцев назад

      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 8 месяцев назад

      ​@@ProfeRafaSTEM lo del numero 1 lo encontre pero el resto no lo entiendo que tengo que cambiar?

    • @federicovega367
      @federicovega367 8 месяцев назад

      Si me puedes responder lo agradeceria

  • @Tr-uc8dz
    @Tr-uc8dz 4 года назад +3

    Mejor canal de arduino, me pasas el código por favor?

    • @RobotUNO
      @RobotUNO  4 года назад +1

      Muchisimas gracias

    • @RobotUNO
      @RobotUNO  4 года назад +2

      //Canal de RUclips -> 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 4 года назад

      Robot UNO abastá

  • @jorgeherreromarcos5963
    @jorgeherreromarcos5963 10 месяцев назад

    Muy chulo!!! Puedes pasarme el código porfa???😁

  • @amaartineez
    @amaartineez 3 года назад +1

    hola brother excelente proyecto tienes el plano de construcción es que va un poco rapido y me e perdido

    • @RobotUNO
      @RobotUNO  3 года назад +2

      No se como hacerlos :( lo siento mucho

    • @amaartineez
      @amaartineez 3 года назад +1

      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 года назад +1

      Vale, lo tendré en cuenta para futuros videos, muchas gracias!

  • @carmat3885
    @carmat3885 7 месяцев назад

    Muchas gracias por el video me puedes pasar el código. Saludos

  • @denisvallejosfelipe637
    @denisvallejosfelipe637 3 года назад +1

    bro ay un herror en el codigo de programacion

  • @IngAndrezael
    @IngAndrezael 3 года назад +1

    Robot UNO, en qué software realizaste el diseño de montaje... Gracias!

  • @KarenRuiz-hk4zj
    @KarenRuiz-hk4zj 3 месяца назад

    Hola , q tal me podrá pasar la programación porfavor 🥺🥺

  • @eliashenao9287
    @eliashenao9287 3 года назад +1

    Agradeciendo por video muy genial. Un favor me puedes enviar el código gracias. 👍✌️

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Muchisimas gracias Elias, aqui tienes el codigo!!

    • @RobotUNO
      @RobotUNO  3 года назад +4

      //Canal de RUclips -> 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í

  • @julianalias81
    @julianalias81 4 года назад +3

    Muy buen proyecto
    Me pasas el código?

    • @RobotUNO
      @RobotUNO  4 года назад +1

      Muchas gracias Julian! en el comentario de abajo te dejo el codigo. Un saludo!

    • @RobotUNO
      @RobotUNO  4 года назад +1

      //Canal de RUclips -> 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);
      }
      }
      }
      }
      }

  • @Vinland-lu8cd
    @Vinland-lu8cd Год назад

    Buenas, podrías pasar la programación para ArduinoBlocks? Gracias!

  • @franciscofalcon1380
    @franciscofalcon1380 3 года назад +1

    como hiciste el montaje en la web?

  • @bassbnst4077
    @bassbnst4077 6 месяцев назад

    Hola me interesa saber el código de programación me lo podrías pasar ?? estoy suscrito

  • @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?

  • @javierornelas7290
    @javierornelas7290 2 года назад

    Me podrías pasar el código porfavor... Exelente proyecto, mi hijo está iniciando gracias ...

  • @adrianpando6158
    @adrianpando6158 3 года назад +1

    No se me prenden todos los leds del 8x8 ya voy comprando dos de los mismos y no funcionan

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Quizas sea otro modelo y alguna conexion sea diferente.

  • @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 8 месяцев назад

    Si ers eso, es la primera que dale LedControl

  • @sandovallarajeseniadelrosa700
    @sandovallarajeseniadelrosa700 2 года назад

    Hola ya estoy suscrita, me puedes pasar el código de programación.?

  • @luisguillermocrosspastrana4269
    @luisguillermocrosspastrana4269 8 месяцев назад

    Compa buenas noches, creo que la falla que me sale es por la librería

  • @user-mf1du9qs6i
    @user-mf1du9qs6i 3 месяца назад

    Me podrias pasar el código de programación porfavor

  • @jordansantiagocruzarcinieg9812
    @jordansantiagocruzarcinieg9812 3 года назад

    Robot uno como me puedo comunicar con usted personalmente gracias 👌🙏

  • @joseguadalupesanchezalvara1394
    @joseguadalupesanchezalvara1394 2 года назад

    Cuanto cuesta el paquete completo para realizarlo?

  • @vicoldayanafonsecaescarrag1116

    Holaaaaa, encontré lo que buscaba, m podrías ayudar con el código? :')

  • @agustina.g7031
    @agustina.g7031 3 года назад +3

    el diagrama de conexión
    esta mal

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Cual es el error?

    • @annettaa2
      @annettaa2 3 года назад +1

      @@RobotUNO Yo te lo he indicado en varios comentarios si lo revisas a lo mejor se puede editar y añadir los arreglos.

  • @g.9843
    @g.9843 2 года назад +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.

  • @jordansantiagocruzarcinieg9812
    @jordansantiagocruzarcinieg9812 3 года назад

    Buenas noches cómo me puedo comunicar con la persona que realizó el proyecto con arduino gracias 👌👌

  • @JESUSMARIAARRIETALOPEZ-w9k
    @JESUSMARIAARRIETALOPEZ-w9k 4 дня назад

    Cuál es el código ?

  • @anderojeda483
    @anderojeda483 Год назад

    hola buen video, podrias pasarme la programacion de este minijuego?

  • @josuelopez8731
    @josuelopez8731 3 года назад

    Amigo cuando subo el codigo me da pero una parte de las Led me encienden pero de ahi no me funciona?

  • @mauriciovazquez7976
    @mauriciovazquez7976 3 года назад

    La programación sería la misma si la haces sin la protoboar

  • @ivanandradezambrano7262
    @ivanandradezambrano7262 3 года назад +1

    Podrías pasarme el código de programación pero yo solo tengo el driver máxim sin modulo

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Claro! aqui lo tienes!

    • @RobotUNO
      @RobotUNO  3 года назад +1

      //Canal de RUclips -> 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);
      }
      }
      }
      }
      }

  • @luisfernandolazcanovillanu9982
    @luisfernandolazcanovillanu9982 2 года назад

    Como puedo integrar esa programación a un 16x16?

  • @RogyerVargas
    @RogyerVargas 2 месяца назад

    Nesecito la programación

  • @miguelangelaguileravelazqu1893

    Hola quisiera el Código oara realizarlo saludos

  • @nombreapellido2231
    @nombreapellido2231 2 года назад

    Cómo se llama la cosita que hace ruido?

  • @luisguillermocrosspastrana4269
    @luisguillermocrosspastrana4269 8 месяцев назад

    Cómo se llama la librería?

  • @sebasarias900
    @sebasarias900 2 года назад

    Alguien me ayuda!!
    Me dice que el "LedControl.h" no existe. Que hago??

  • @DavidPalmerin-sp3jt
    @DavidPalmerin-sp3jt Год назад

    Puedes pasar la programación por favor 😁😁😁😁

  • @cirouribe6976
    @cirouribe6976 Год назад

    Hola me pasas el codigo de programacion por favor

  • @pvz2058
    @pvz2058 4 года назад +1

    Mándame el código, por cierto me encanto el vídeo bro

    • @RobotUNO
      @RobotUNO  4 года назад +1

      Muchas gracias Gabriel! Aqui tienes el codigo!

    • @RobotUNO
      @RobotUNO  4 года назад +3

      //Canal de RUclips -> 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);
      }
      }
      }
      }
      }

  • @isaibarreto9360
    @isaibarreto9360 2 года назад

    bro tienes el diagrama esquemático por favor

  • @mtra.loredecena3680
    @mtra.loredecena3680 2 года назад

    Buen día, me puede pasar el código por favor.

  • @lost_kazzy7953
    @lost_kazzy7953 Год назад

    Hola puedes pasarme el código de programación

  • @saidvalerav2048
    @saidvalerav2048 4 года назад +1

    hola me das un consejo para mejorar mi canal

    • @RobotUNO
      @RobotUNO  4 года назад +2

      Hazlo por que te gusta, no por el dinero ni nada. RUclips ya no es como antes

    • @saidvalerav2048
      @saidvalerav2048 4 года назад +1

      @@RobotUNO gracias este es el mejor canal

  • @soymaxmilla
    @soymaxmilla 3 года назад +1

    Me podrías dar la programación ?, Sirve igual que con una matriz led de 16x16

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Habria que cambiar algunos parametros en la programacion. Aqui tienes el codigo!

    • @RobotUNO
      @RobotUNO  3 года назад +2

      //Canal de RUclips -> 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 года назад +1

      @@RobotUNO Cual seria la programación para que la comida de la serpiente salga de otro color ??

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Estas matrices estan compuestas por leds de color rojo, asi que es algo imposible :(

  • @sergioandrescadena4277
    @sergioandrescadena4277 2 года назад

    Me gusto el proyecto me puedes enviar el código me

  • @weedsoldier2
    @weedsoldier2 9 месяцев назад

    Bueno y el código?

  • @denisvallejosfelipe637
    @denisvallejosfelipe637 3 года назад

    buem proyecto me encanto me pasarias el el codigo porfa

  • @stivensanchez7850
    @stivensanchez7850 8 месяцев назад

    alguien me ayuda el código le da error ayúdame

  • @ingridortiz4185
    @ingridortiz4185 2 года назад

    Podrías pasar el código...

  • @rubimurillo4901
    @rubimurillo4901 3 года назад

    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 года назад +1

      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.

  • @user-ev2hm4wl7m
    @user-ev2hm4wl7m 10 месяцев назад

    Necesito el código porff

  • @jorgeroberto1733
    @jorgeroberto1733 Год назад

    Hola Master pasame el codigo desde ya gtacias

  • @DAER-wt5tm
    @DAER-wt5tm 4 года назад +1

    Hola bro, una pregunta, el código no me lo acepta. Por cierto nuevo suscripitor, ;)

    • @RobotUNO
      @RobotUNO  4 года назад +3

      Cual es el error?? has instalado la libreria?

    • @DAER-wt5tm
      @DAER-wt5tm 4 года назад

      @@RobotUNO si ya la instale, es la parte, #include "LedControl.h", me carga error

    • @DAER-wt5tm
      @DAER-wt5tm 4 года назад +1

      disculpa bro, fue mi error, pero gracias y buen video

    • @urielperezgomez3112
      @urielperezgomez3112 3 года назад

      El mio si es la librería ¿Puedes ayudarme en eso?

  • @claudiamerlos1817
    @claudiamerlos1817 2 года назад

    Hola me podrías dar el código?

  • @GabrielSbro
    @GabrielSbro 7 месяцев назад

    Código?

  • @denilsonizaguirre8750
    @denilsonizaguirre8750 29 дней назад

    Necesito en codigo

  • @RogyerVargas
    @RogyerVargas 2 месяца назад

    La programación porfaaaaa

  • @borjaaltamiraareizaga6532
    @borjaaltamiraareizaga6532 3 года назад +1

    Hola, me gusta mucho! Podrías enviarme el código de programación? Muchas gracias!

    • @RobotUNO
      @RobotUNO  3 года назад +3

      //Canal de RUclips -> 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 года назад +1

      @@RobotUNO muchas gracias!

  • @user-ku2nn6kv4q
    @user-ku2nn6kv4q Год назад

    hola el codigo porfavor

  • @mari0_gomezz
    @mari0_gomezz 3 года назад +1

    Hola, no me funciona el código.

    • @RobotUNO
      @RobotUNO  3 года назад +2

      Has instalado las librerias correspondientes? quizas sea eso

    • @revillaaldaveracristian9451
      @revillaaldaveracristian9451 3 года назад +1

      Que librería es?

    • @annettaa2
      @annettaa2 3 года назад +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 года назад +1

      @@annettaa2 Vale, muchísimas gracias

  • @RogyerVargas
    @RogyerVargas 2 месяца назад

    Por fvaro

  • @alexmoreyt8930
    @alexmoreyt8930 4 года назад +2

    me ouedes pasar el codigo?

    • @RobotUNO
      @RobotUNO  4 года назад +2

      CLARO!!! aqui lo tienes!

    • @RobotUNO
      @RobotUNO  4 года назад +1

      //Canal de RUclips -> 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 4 года назад +1

      @@RobotUNO muchas graicas

    • @alexmoreyt8930
      @alexmoreyt8930 4 года назад +1

      @@RobotUNO tengo una duda,ami no me sale ""LedControl.h" como le puedo hacer?

    • @RobotUNO
      @RobotUNO  4 года назад +1

      tienes que instalarte la libreria

  • @desticgamer5947
    @desticgamer5947 3 года назад +2

    No me funciono el código

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Cual de todos?? tienes instaladas las librerias?

    • @desticgamer5947
      @desticgamer5947 3 года назад +1

      @@RobotUNO tengo instalada el programa meter el código pero no me va el código

    • @desticgamer5947
      @desticgamer5947 3 года назад +1

      @@RobotUNO me interesa mucho tu proyecto y la verdad no se si abra un forma de comunicarse con Tigo

    • @RobotUNO
      @RobotUNO  3 года назад +2

      Puedes hablarme por correo electronico si quieres "manualidadesyarmas@gmail.com"

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Has instalado la libreria "LedControl.h"?? Se hace desde la aplicacion de arduino IDE

  • @jackmendeztesucun6228
    @jackmendeztesucun6228 Год назад

    Necesito el código

  • @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 RUclips -> 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

  • @user-np3gg8um4x
    @user-np3gg8um4x 11 месяцев назад

    Pasa el código

  • @eduardocorchs8904
    @eduardocorchs8904 3 года назад +1

    me podrias pasar la libreria

    • @RobotUNO
      @RobotUNO  3 года назад +1

      Aqui tienes el codigo Eduardo!

    • @RobotUNO
      @RobotUNO  3 года назад +1

      //Canal de RUclips -> 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 года назад +2

      La libreria ledcontrol.h la puedes encontrar en el propio programa de arduino. Un saludo,.

    • @mauricioordonezcarvajal5836
      @mauricioordonezcarvajal5836 3 года назад +1

      @@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

  • @1MegamaX200
    @1MegamaX200 2 года назад

    Pásame la progamacion