Saturday, January 6, 2024

Pemrograman Running text P10 RGB dengan Arduino Nano

Pemrograman Running text P10 RGB dengan Arduino Nano





PIN CONNECTION P10 RGB DENGAN ARDUINO NANO/UNO






Source code arduino p10 RGB


 #include "RGBmatrixPanel.h"

#define CLK  8 

#define OE   9

#define LAT 10 //A3

#define A   A0

#define B   A1

#define C   A2


RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);


// Similar to F(), but for PROGMEM string pointers rather than literals

#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr


const char str[] PROGMEM = "Belajar Tehnologi Jaman Now - Channel Tentang belajar tehnologi jaman now";

int16_t    textX         = matrix.width(),

           textMin       = (int16_t)sizeof(str) * -12,

           hue           = 0;


//matrix.width(),

          

int8_t ball[3][4] = {

  {  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls

  { 17, 15,  1, -1 },

  { 27,  4, -1,  1 }

};


static const uint16_t PROGMEM ballcolor[3] = {

  0x0080, // Green=1

  0x0002, // Blue=1

  0x1000  // Red=1

};


/*

static const uint16_t PROGMEM ballcolor[3] = {

  0x0000, // Green=1

  0x0000, // Blue=1

  0x0000  // Red=1

};

*/

void setup() {

  matrix.begin();

  matrix.setTextWrap(false); // Allow text to run off right edge

  matrix.setTextSize(1);


}



void circle(int lama)

{

  byte i;byte j;

  int lama1=lama;


  for(j=0; j<lama1; j++) {

  matrix.fillScreen(0);



  // Bounce three balls around


  for(i=0; i<3; i++) {

    // Draw 'ball'

    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));

    // Update X, Y position

    ball[i][0] += ball[i][2];

    ball[i][1] += ball[i][3];

    // Bounce off edges

    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))

      ball[i][2] *= -1;

    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))

      ball[i][3] *= -1;

  }

  delay(10);

  }

}



void loop()

{

matrix.fillScreen(0);

circle(200);

matrix.fillScreen(0);

running_text(200);  

matrix.fillScreen(0);

running_gabungan(200);

matrix.fillScreen(0);

}


void running_text(int lama) {

  byte i;byte j;

  int lama1=lama;

  hue=0;


           textX         = matrix.width();

           textMin       = (int16_t)sizeof(str) * -12;

           hue           = 0;

           

  for(j=0; j<lama; j++) {


    


  // Clear background

  matrix.fillScreen(0);

  matrix.setTextColor(matrix.ColorHSV(hue, 255, 10, true));

 

  matrix.setTextSize(1);

  // Bounce three balls around

 /*

  for(i=0; i<3; i++) {

    // Draw 'ball'

    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));

    // Update X, Y position

    ball[i][0] += ball[i][2];

    ball[i][1] += ball[i][3];

    // Bounce off edges

    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))

      ball[i][2] *= -1;

    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))

      ball[i][3] *= -1;

  }

*/

  // Draw big scrolly text on top

  matrix.setTextColor(matrix.ColorHSV(hue, 255, 100, true));

  matrix.setCursor(textX, 4);

  matrix.print(F2(str));

  

delay(25);


 

  // Move text left (w/wrap), increase hue

 if((--textX) < textMin) textX = matrix.width();

  hue += 7;

  if(hue >= 1536) hue -= 1536;  //1536


#if !defined(__AVR__)

  // On non-AVR boards, delay slightly so screen updates aren't too quick.

 delay(120);

#endif


  // Update display

  matrix.swapBuffers(false);

  }

}





void running_gabungan(int lama) {

  byte i;byte j;

  int lama1=lama;

  hue=0;

             textX         = matrix.width();

           textMin       = (int16_t)sizeof(str) * -12;

           hue           = 0;


  for(j=0; j<lama; j++) {


    


  // Clear background

  matrix.fillScreen(0);

  matrix.setTextColor(matrix.ColorHSV(hue, 255, 100, true));

 

  matrix.setTextSize(2);

  // Bounce three balls around


  for(i=0; i<3; i++) {

    // Draw 'ball'

    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));

    // Update X, Y position

    ball[i][0] += ball[i][2];

    ball[i][1] += ball[i][3];

    // Bounce off edges

    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))

      ball[i][2] *= -1;

    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))

      ball[i][3] *= -1;

  }


  // Draw big scrolly text on top

  matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));

  matrix.setCursor(textX, 1);

  matrix.print(F2(str));

  

  delay(10);


 

  // Move text left (w/wrap), increase hue

 if((--textX) < textMin) textX = matrix.width();

  hue += 7;

  if(hue >= 1536) hue -= 1536;  //1536


#if !defined(__AVR__)

  // On non-AVR boards, delay slightly so screen updates aren't too quick.

 delay(120);

#endif


  // Update display

  matrix.swapBuffers(false);

  }

}

Pemrograman Running text P10 RGB dengan Arduino Nano

Pemrograman Running text P10 RGB dengan Arduino Nano PIN CONNECTION P10 RGB DENGAN ARDUINO NANO/UNO Source code arduino p10 RGB  #include &q...