كيفية تركيب شاشة MAX7219 على روبوت الذكي مع البرمجة عليه | Robot Smart Tank TP100 - DIY Channel3

DIY Channel3

Arduino│ESP8266│ESP32│Drone│Robot

كيفية تركيب شاشة MAX7219 على روبوت الذكي مع البرمجة عليه | Robot Smart Tank TP100

مشاركة هذا

 


مخطط الرسم البياني


 

كود اردوينو

 


#include <MD_Parola.h>

#include <MD_MAX72xx.h>

#include <SPI.h>


// Define hardware type, size, and output pins:

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

#define MAX_DEVICES 8

#define CS_PIN 3


// Create a new instance of the MD_Parola class with hardware SPI connection:

MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);


// Setup for software SPI:

// #define DATA_PIN 2

// #define CLK_PIN 4

// MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);


// Sprite definitions:

const uint8_t F_PMAN1 = 6;

const uint8_t W_PMAN1 = 8;

const uint8_t PROGMEM pacman1[F_PMAN1 * W_PMAN1] =  // gobbling pacman animation

{

  0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c,

  0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c,

  0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c,

  0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c,

  0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c,

  0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c,

};


const uint8_t F_PMAN2 = 6;

const uint8_t W_PMAN2 = 18;

const uint8_t PROGMEM pacman2[F_PMAN2 * W_PMAN2] =  // pacman pursued by a ghost

{

  0x00, 0x81, 0xc3, 0xe7, 0xff, 0x7e, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

  0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

  0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

  0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

  0x24, 0x66, 0xe7, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

  0x00, 0x42, 0xe7, 0xe7, 0xff, 0xff, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0xfe, 0x7b, 0xf3, 0x7f, 0xfb, 0x73, 0xfe,

};


const uint8_t F_WAVE = 14;

const uint8_t W_WAVE = 14;

const uint8_t PROGMEM wave[F_WAVE * W_WAVE] =  // triangular wave / worm

{

  0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10,

  0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20,

  0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40,

  0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,

  0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40,

  0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20,

  0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10,

  0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04, 0x08,

  0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02, 0x04,

  0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x02,

  0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01,

  0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02,

  0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04,

  0x04, 0x02, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08,

};


const uint8_t F_ROLL1 = 4;

const uint8_t W_ROLL1 = 8;

const uint8_t PROGMEM roll1[F_ROLL1 * W_ROLL1] =  // rolling square

{

  0xff, 0x8f, 0x8f, 0x8f, 0x81, 0x81, 0x81, 0xff,

  0xff, 0xf1, 0xf1, 0xf1, 0x81, 0x81, 0x81, 0xff,

  0xff, 0x81, 0x81, 0x81, 0xf1, 0xf1, 0xf1, 0xff,

  0xff, 0x81, 0x81, 0x81, 0x8f, 0x8f, 0x8f, 0xff,

};


const uint8_t F_ROLL2 = 4;

const uint8_t W_ROLL2 = 8;

const uint8_t PROGMEM roll2[F_ROLL2 * W_ROLL2] =  // rolling octagon

{

  0x3c, 0x4e, 0x8f, 0x8f, 0x81, 0x81, 0x42, 0x3c,

  0x3c, 0x72, 0xf1, 0xf1, 0x81, 0x81, 0x42, 0x3c,

  0x3c, 0x42, 0x81, 0x81, 0xf1, 0xf1, 0x72, 0x3c,

  0x3c, 0x42, 0x81, 0x81, 0x8f, 0x8f, 0x4e, 0x3c,

};


const uint8_t F_LINES = 3;

const uint8_t W_LINES = 8;

const uint8_t PROGMEM lines[F_LINES * W_LINES] =  // spaced lines

{

  0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00,

  0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00,

  0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,

};


const uint8_t F_ARROW1 = 3;

const uint8_t W_ARROW1 = 10;

const uint8_t PROGMEM arrow1[F_ARROW1 * W_ARROW1] =  // arrow fading to center

{

  0x18, 0x3c, 0x7e, 0xff, 0x7e, 0x00, 0x00, 0x3c, 0x00, 0x00,

  0x18, 0x3c, 0x7e, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x18, 0x00,

  0x18, 0x3c, 0x7e, 0xff, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x18,

};


const uint8_t F_ARROW2 = 3;

const uint8_t W_ARROW2 = 9;

const uint8_t PROGMEM arrow2[F_ARROW2 * W_ARROW2] =  // arrow fading to outside

{

  0x18, 0x3c, 0x7e, 0xe7, 0x00, 0x00, 0xc3, 0x00, 0x00,

  0x18, 0x3c, 0x7e, 0xe7, 0xe7, 0x00, 0x00, 0x81, 0x00,

  0x18, 0x3c, 0x7e, 0xe7, 0x00, 0xc3, 0x00, 0x00, 0x81,

};


const uint8_t F_SAILBOAT = 1;

const uint8_t W_SAILBOAT = 11;

const uint8_t PROGMEM sailboat[F_SAILBOAT * W_SAILBOAT] =  // sail boat

{

  0x10, 0x30, 0x58, 0x94, 0x92, 0x9f, 0x92, 0x94, 0x98, 0x50, 0x30,

};


const uint8_t F_STEAMBOAT = 2;

const uint8_t W_STEAMBOAT = 11;

const uint8_t PROGMEM steamboat[F_STEAMBOAT * W_STEAMBOAT] =  // steam boat

{

  0x10, 0x30, 0x50, 0x9c, 0x9e, 0x90, 0x91, 0x9c, 0x9d, 0x90, 0x71,

  0x10, 0x30, 0x50, 0x9c, 0x9c, 0x91, 0x90, 0x9d, 0x9e, 0x91, 0x70,

};


const uint8_t F_HEART = 5;

const uint8_t W_HEART = 9;

const uint8_t PROGMEM heart[F_HEART * W_HEART] =  // beating heart

{

  0x0e, 0x11, 0x21, 0x42, 0x84, 0x42, 0x21, 0x11, 0x0e,

  0x0e, 0x1f, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x1f, 0x0e,

  0x0e, 0x1f, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1f, 0x0e,

  0x0e, 0x1f, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x1f, 0x0e,

  0x0e, 0x11, 0x21, 0x42, 0x84, 0x42, 0x21, 0x11, 0x0e,

};


const uint8_t F_INVADER = 2;

const uint8_t W_INVADER = 10;

const uint8_t PROGMEM invader[F_INVADER * W_INVADER] =  // space invader

{

  0x0e, 0x98, 0x7d, 0x36, 0x3c, 0x3c, 0x36, 0x7d, 0x98, 0x0e,

  0x70, 0x18, 0x7d, 0xb6, 0x3c, 0x3c, 0xb6, 0x7d, 0x18, 0x70,

};


const uint8_t F_ROCKET = 2;

const uint8_t W_ROCKET = 11;

const uint8_t PROGMEM rocket[F_ROCKET * W_ROCKET] =  // rocket

{

  0x18, 0x24, 0x42, 0x81, 0x99, 0x18, 0x99, 0x18, 0xa5, 0x5a, 0x81,

  0x18, 0x24, 0x42, 0x81, 0x18, 0x99, 0x18, 0x99, 0x24, 0x42, 0x99,

};


const uint8_t F_FBALL = 2;

const uint8_t W_FBALL = 11;

const uint8_t PROGMEM fireball[F_FBALL * W_FBALL] =  // fireball

{

  0x7e, 0xab, 0x54, 0x28, 0x52, 0x24, 0x40, 0x18, 0x04, 0x10, 0x08,

  0x7e, 0xd5, 0x2a, 0x14, 0x24, 0x0a, 0x30, 0x04, 0x28, 0x08, 0x10,

};


const uint8_t F_CHEVRON = 1;

const uint8_t W_CHEVRON = 9;

const uint8_t PROGMEM chevron[F_CHEVRON * W_CHEVRON] =  // chevron

{

  0x18, 0x3c, 0x66, 0xc3, 0x99, 0x3c, 0x66, 0xc3, 0x81,

};


const uint8_t F_WALKER = 5;

const uint8_t W_WALKER = 7;

const uint8_t PROGMEM walker[F_WALKER * W_WALKER] =  // walking man

{

  0x00, 0x48, 0x77, 0x1f, 0x1c, 0x94, 0x68,

  0x00, 0x90, 0xee, 0x3e, 0x38, 0x28, 0xd0,

  0x00, 0x00, 0xae, 0xfe, 0x38, 0x28, 0x40,

  0x00, 0x00, 0x2e, 0xbe, 0xf8, 0x00, 0x00,

  0x00, 0x10, 0x6e, 0x3e, 0xb8, 0xe8, 0x00,

};


void setup() {

  myDisplay.begin();

  myDisplay.setIntensity(0);

  myDisplay.displayClear();

  myDisplay.setSpriteData(pacman2, W_PMAN2, F_PMAN2, pacman2, W_PMAN2, F_PMAN2);

  myDisplay.displayText("Parola sprites", PA_CENTER, 50, 1000, PA_SPRITE, PA_SPRITE);

}


void loop() {

  if (myDisplay.displayAnimate()) {

    myDisplay.displayReset();

  }

}

No comments:

Post a Comment