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);

  }

}

Saturday, January 7, 2023

Running text jam digital dengan max 7219 dan Nodemcu esp8266 lolin v3 lua ch340G



#include <MD_Parola.h>

#include <MD_MAX72xx.h>

#include <SPI.h>

#include <Wire.h>                        // DS3231clock

#include "RTClib.h"                      // DS3132 clock


/* JAM MEJA DIGITAL DENGAN RUNNING TEXT TGL

 *  KOMPONEN

 *  - ARDUINO

 *  - RTC DS 3231

 *  MODIFIED : APLIKASI-HEBAT STDUIO

 *  DATE MODIFIED : 8 Jan 2023 

 *  

RTC3231   -------->       NODEMCU LOLIN V3 LUA CH340G ESP8266 IOT WIFI   

SCL                       D1

SDA                       D2

VCC                       3.3V

GND                      GND



MAX7219   ------>      NODEMCU LOLIN V3 LUA CH340G ESP8266 IOT WIFI 

CS                           8

CLK                          7

DIN                          6

VCC                          3.3V

GND                         GND


 */


//init

RTC_DS3231 rtc3231;


#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

#define MAX_DEVICES 4
#define CLK_PIN   D7 

#define DATA_PIN  D6  
#define CS_PIN    D8 


MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);



uint8_t scrollSpeed = 60;    // default frame delay value


textEffect_t scrollEffect = PA_SCROLL_LEFT;

textPosition_t scrollAlign = PA_LEFT;

uint16_t scrollPause = 20; // keceptan running text in milliseconds


// Global message buffers shared by Serial and Scrolling functions

#define  BUF_SIZE  175

//int pjg=myString.length(); 

char curMessage[BUF_SIZE] = { "" };


char c[100];

 

int tahun;

int bulan;

int tgl;

int jam; 

int menit;

int detik;

int blink=0;

int blink1=0;

int dayoffweek;

String s;


String Hari[7] = {

  "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"

};


bool newMessageAvailable = true;


void setup()

{

  //pinMode(1, OUTPUT);

  

 // Wire.begin(1,2);

  rtc3231.begin();

  P.begin();

  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);


  P.setIntensity(5);

  // Clear the display:

  P.displayClear();

  //setting jam pertama kali

 // rtc3231.adjust(DateTime(2023, 1, 8, 9, 9, 0));

  

}


void loop()

{

//P.setTextAlignment(PA_CENTER);

get_time();



//int detik=29;


s=Hari[dayoffweek] + " TGL "+ Konversi(tgl)+"-"+ Konversi(bulan)+ "-"+ Konversi(tahun)+" JAM "+ Konversi(jam)+ ":"+ Konversi(menit)+"          ";

s.toUpperCase();

s.toCharArray(c, s.length()+1);

//P.displayReset();


//readSerial();

if (blink<=1)

{

  if (P.displayAnimate())

  {

    if (newMessageAvailable)

    {

     //strcpy(curMessage, newMessage);

      strcpy(curMessage, c);

      newMessageAvailable = false;

    }else { 

      blink++;

      //P.displayClear();

      newMessageAvailable = true;

      P.displayText("welcome", PA_CENTER, scrollSpeed, 1000, PA_OPENING_CURSOR,PA_OPENING_CURSOR);

      P.displayReset();

      

      }


    

    P.displayReset();

  }

  


} else

{

  blink++;

  if (blink1==0)

  {

  P.print(Konversi(jam)+ ":"+ Konversi(menit));

  blink1=1;

  } else

  {

    P.print(Konversi(jam)+ " "+ Konversi(menit));

    blink1=0;

  }

  delay(1000);



  

  if( blink>=30) {

    blink=0;P.displayClear();

    newMessageAvailable = true;

    P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);

  }

}



}


String Konversi(int sInput) {

  if (sInput < 10)

  {

    return"0" + String(sInput);

  }

  else

  {

    return String(sInput);

  }

}


void get_time()

{

  DateTime now= rtc3231.now();

  //save time to array

  tahun= now.year();

  bulan = now.month();

  tgl = now.day();

  dayoffweek = now.dayOfTheWeek(); //returns 0-6 where 0 = Sunday

  jam = now.hour();

  menit = now.minute();

  detik = now.second();

}




Saturday, October 29, 2022

GAMBAR MASJID P10 1 PANEL DENGAN NANO

 /* JUDUL : PROGRAM JAM DIGITAL P10 1 PANEL DENGAN NANO & RTC 3231

 * COPY RIGHT : BELAJAR TEHNOLOGI JAMAN NOW

 * PUBLISH : 13 MAR 2022

 * EMAIL   : aplikasihebatstudio@gmail.com

 * 

 * NANO - P10

 * ----------

 * PIN YANG DISAMBUNG

 * Arduino              P-10

 * D6          ->      A

 * D7          ->      B

 * D8          ->      SCLK

 * D9          ->      OE (ENABLE)

 * D11         ->      DATA

 * D13         ->      CLK

 * GND         ->      GND


RTC 3231

--------

 * GND        >>      Pin GND

 * VCC        >>      Pin 5V

 * SDA        >>      Pin SDA  (A4)

 * SCL        >>      Pin SCL (A5)

 * SQW        >>      tidak dihubungkan

 * 32K        >>      tidak dihubungkan


*/



#include <Wire.h> 

#include "RTClib.h" 

#include "DMD.h"        

#include "TimerOne.h"

#include "SystemFont5x7.h"

#include "angka6x13.h"

#include "angka_2.h"


#define DISPLAYS_ACROSS 1

#define DISPLAYS_DOWN 1


/***** P10 DISPLAY SETTING ***********************************/

DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN);


RTC_DS3231 rtc;



 // int tahun;                                                                              

  byte jam;

  byte menit;                                                                                                                                                                    //| 

  byte detik;

 


 

 void drawText(int kolom,int baris,String text);

   

void ScanDMD()

{

  dmd.scanDisplayBySPI();

}




void setup()

{  

  Timer1.initialize( 4000 );   // I find the default 5000 gives a visible flicker    

  Timer1.attachInterrupt( ScanDMD );  

  dmd.selectFont(SystemFont5x7);

  dmd.clearScreen( true );

   Wire.begin();

   rtc.begin();

 // just datatime  

 //  rtc.adjust(DateTime(2022, 03, 12, 12, 8, 0));


}



void loop()

{

  jam_besar(10);

  gambar_masjid();

  delay(5000);

  drawText1(32,16," ");

  delay(1000);

}



void jam_besar(int lama)

{


 dmd.clearScreen(true);

//dmd.drawBox(32,0,63,15,GRAPHICS_ON);


  for (int i=0;i<=lama;i++)

  {

   DateTime now = rtc.now();

int jam= now.hour();

int menit=now.minute();

int detik=now.second();

String waktu1=Konversi(jam)+":"+Konversi(menit)+":"+Konversi(detik);

String waktu2=Konversi(jam)+" "+Konversi(menit)+" "+Konversi(detik);;


    



dmd.selectFont(angka6x13); 

drawText(1, 0, Konversi(jam)); //koordinat tampilan

//titik 2

dmd.drawLine(16,4,16,5,GRAPHICS_NORMAL);

dmd.drawLine(15,4,15,5,GRAPHICS_NORMAL);


dmd.drawLine(16,9,16,10,GRAPHICS_NORMAL);

dmd.drawLine(15,9,15,10,GRAPHICS_NORMAL);


dmd.selectFont(angka6x13);

drawText(18, 0, Konversi(menit));


 delay(500);

dmd.drawLine(16,4,16,5,GRAPHICS_NOR);

dmd.drawLine(15,4,15,5,GRAPHICS_NOR);

dmd.drawLine(16,9,16,10,GRAPHICS_NOR);

dmd.drawLine(15,9,15,10,GRAPHICS_NOR);


 delay(500);

 }


 dmd.clearScreen(true);

}



void drawText(int kolom,int baris,String text)

{

int pj_text=text.length()+1;

char text_char[pj_text];

text.toCharArray(text_char,pj_text);

dmd.drawString(kolom,baris,text_char,pj_text,GRAPHICS_NORMAL);





///Konversi angka agar ada nol didepannya jika diawah 10

String Konversi(int sInput) {

  if (sInput < 10)

  {

    return"0" + String(sInput);

  }

  else

  {

    return String(sInput);

  }

}



void gambar_masjid()

{

int GRAPHICS_ON=GRAPHICS_NORMAL;

// dmd.clearScreen(true);

//dmd.drawBox(32,0,63,15,GRAPHICS_ON);

//gambar masjid

//kiri

dmd.drawLine(0,6,0,6,GRAPHICS_NORMAL);

dmd.drawLine(1,5,1,15,GRAPHICS_ON);

dmd.drawLine(2,0,2,13,GRAPHICS_ON);

dmd.drawLine(3,5,3,15,GRAPHICS_ON);

dmd.drawLine(4,6,4,6,GRAPHICS_ON);

//tengah


dmd.drawLine(15,0,15,0,GRAPHICS_ON);

dmd.drawLine(14,1,16,1,GRAPHICS_ON);

dmd.drawLine(13,2,17,2,GRAPHICS_ON);

dmd.drawLine(12,3,18,3,GRAPHICS_ON);

dmd.drawLine(11,4,19,4,GRAPHICS_ON);

dmd.drawLine(11,5,19,5,GRAPHICS_ON);

dmd.drawLine(12,6,18,6,GRAPHICS_ON);

dmd.drawLine(13,7,17,7,GRAPHICS_ON);

dmd.drawLine(5,8,25,8,GRAPHICS_ON);

dmd.drawLine(5,10,25,10,GRAPHICS_ON);

dmd.drawLine(5,11,7,11,GRAPHICS_ON);dmd.drawLine(9,11,14,11,GRAPHICS_ON);dmd.drawLine(16,11,21,11,GRAPHICS_ON);dmd.drawLine(23,11,25,11,GRAPHICS_ON);

dmd.drawLine(5,12,6,12,GRAPHICS_ON);dmd.drawLine(10,12,13,12,GRAPHICS_ON);dmd.drawLine(17,12,20,12,GRAPHICS_ON);dmd.drawLine(24,12,25,12,GRAPHICS_ON);

dmd.drawLine(5,13,6,13,GRAPHICS_ON);dmd.drawLine(10,13,13,13,GRAPHICS_ON);dmd.drawLine(17,13,20,13,GRAPHICS_ON);dmd.drawLine(24,13,25,13,GRAPHICS_ON);

dmd.drawLine(5,14,6,14,GRAPHICS_ON);dmd.drawLine(10,14,13,14,GRAPHICS_ON);dmd.drawLine(17,14,20,14,GRAPHICS_ON);dmd.drawLine(24,14,25,14,GRAPHICS_ON);

dmd.drawLine(5,15,25,15,GRAPHICS_ON);

//kanan

dmd.drawLine(26,6,26,6,GRAPHICS_ON);

dmd.drawLine(27,5,27,15,GRAPHICS_ON);

dmd.drawLine(28,0,28,13,GRAPHICS_ON);

dmd.drawLine(29,5,29,15,GRAPHICS_ON);

dmd.drawLine(30,6,30,6,GRAPHICS_ON);

//delay(2000);


}




void drawText1(int kolom,int baris,String text)

{

long RandNumX;

long RandNumY;


//RandNumX=random(kolom);

//RandNumY=random(baris);


for(int i=0;i<1500;i++)

{

RandNumX=random(kolom);

RandNumY=random(baris);

dmd.drawLine( RandNumX, RandNumY, RandNumX+2, RandNumY+2, GRAPHICS_NOR );

delay(1);

}

//dmd.drawString(kolom,baris,text_char,pj_text,GRAPHICS_NOR);

}






Sunday, June 26, 2022

Membuat running text untuk mobil keren ( Arduino Source Code )

 //#Running text untuk mobil atau motor#


#include <MD_Parola.h>

#include <MD_MAX72xx.h>

#include <SPI.h>



#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

#define MAX_DEVICES 4

#define CLK_PIN   7 

#define DATA_PIN  6 

#define CS_PIN    8  


#define kiri 3

#define kanan 4

#define rem 5


// HARDWARE SPI

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


int i = 0;

int j=0;

int k=0;



void panah_kiri();

void panah_kanan();

void Stop_blink();

void Rem_blink();


textEffect_t texteffect[] =

{

  PA_PRINT,

  PA_SCAN_HORIZ,

  PA_SCROLL_LEFT,

  PA_WIPE,

  PA_SCROLL_UP_LEFT,

  PA_SCROLL_UP,

  PA_OPENING_CURSOR,

  PA_GROW_UP,

  PA_MESH,

  PA_SCROLL_UP_RIGHT,

  PA_BLINDS,

  PA_CLOSING,

  PA_RANDOM,

  PA_GROW_DOWN,

  PA_SCAN_VERT,

  PA_SCROLL_DOWN_LEFT,

  PA_WIPE_CURSOR,

  PA_DISSOLVE,

  PA_OPENING,

  PA_CLOSING_CURSOR,

  PA_SCROLL_DOWN_RIGHT,

  PA_SCROLL_RIGHT,

  PA_SLICE,

  PA_SCROLL_DOWN

};


void setup() {

  pinMode(kiri, INPUT);

  pinMode(kanan, INPUT);

  pinMode(rem, INPUT);

  myDisplay.begin();

  myDisplay.setIntensity(5);

  myDisplay.setTextAlignment(PA_CENTER);

  myDisplay.setPause(1000);

  myDisplay.setSpeed(20);

  myDisplay.displayClear();

}



void loop() {

   int tombolkiri=digitalRead(kiri);

   int tombolkanan=digitalRead(kanan);

   int tombolrem=digitalRead(rem);


   if (tombolkiri==1 and tombolkanan==1)

    {

      Hati2_blink();

    }

  

   if (tombolkiri==1)

    {

      j++;

      if(j==1)

      {

        // myDisplay.displayReset();

         myDisplay.displayClear();

         myDisplay.print("                            ");  

      }

      panah_kiri();

      k=0;

    } 

    else if (tombolkanan==1)

    {

      j++;

      if(j==1)

      {

         myDisplay.displayClear();

         myDisplay.print("                            ");  

      }

      panah_kanan();

      k=0;

    }

    else if (tombolrem==1)

    {

      Stop_blink();

    }

    else

    {

      j=0;

      k++;

       if(k==1)

      {

         myDisplay.displayClear();

         myDisplay.print("                            ");  

      }


      if ( k>10) {k=2;}

      myDisplay.setIntensity(2);

      myDisplay.setTextAlignment(PA_CENTER);

      myDisplay.setPause(1);

      myDisplay.setSpeed(30);

 

    

     if (myDisplay.displayAnimate()) {

      i=2;

      myDisplay.displayText("Welcome to Youtube Channel Belajar Tehnologi jaman Now", myDisplay.getTextAlignment(), myDisplay.getSpeed(), myDisplay.getPause(), texteffect[i], texteffect[i]);

      myDisplay.displayReset();

     }

    }

 

}



void panah_kiri()

{

  myDisplay.setIntensity(5);

  myDisplay.setTextAlignment(PA_CENTER);

  myDisplay.setPause(0);

  myDisplay.setSpeed(20);

 

if (myDisplay.displayAnimate()) {

      i=2; 

      myDisplay.displayText("<<<< <<<< <<<< <<<<", myDisplay.getTextAlignment(), myDisplay.getSpeed(), myDisplay.getPause(), texteffect[i], texteffect[i]);

     myDisplay.displayReset();

     }

}



void panah_kanan()

{

  myDisplay.setIntensity(5);

  myDisplay.setTextAlignment(PA_CENTER);

  myDisplay.setPause(0);

  myDisplay.setSpeed(20);

 

if (myDisplay.displayAnimate()) {

      i=21; 

      myDisplay.displayText(">>>> >>>> >>>> >>>>", myDisplay.getTextAlignment(), myDisplay.getSpeed(), myDisplay.getPause(), texteffect[i], texteffect[i]);

     myDisplay.displayReset();

     }

}


void Stop_blink()

{

myDisplay.print("<STOP>");

delay(200);

myDisplay.print("         ");  

delay(200);

}


void Hati2_blink()

{

myDisplay.print("Hati2 ");

delay(200);

myDisplay.print("         ");  

delay(200);

}


Monday, March 7, 2022

DIGITAL CLOCK USING ARDUINO WEMOS D1 + TM 1637 + RTC DS 1307

 




Arduino program

/***************

 * Digital clock Wemos + TM 1637 + DS 1307 

 * TM1637 dan Arduino Wemos

 * youtube channel : Belajar tehnologi jaman now

Koneksi antar Pin :

Wemos                                TM1637
D5                    ------>          CLK     
D6                    ------>          DIO
VCC/3V3        ------>          VCC
GND                ------>          GND


Wemos                               RTC1307
D1                    ------>           SCL 
D2                    ------>           SDA
VCC/3V3        ------>          VCC
GND                ------>         GND

 ***************/

//Library modul TM1637

#include <TM1637Display.h>

#include <Wire.h>

#include "RTClib.h"


RTC_DS1307 rtc;

//koneksi pin CLK ke pin D5 Arduino

//koneksi pin DIO ke pin D6 Arduino

#define CLK D5

#define DIO D6


TM1637Display display(CLK, DIO);


void setup()

{

  rtc.begin();

  display.clear();

  display.setBrightness(0x05);  

  //setting jam pertama kali

 // rtc.adjust(DateTime(2022, 3, 6, 22, 26, 0));

}


void loop()

{  


  DateTime now = rtc.now();

  int jam=now.hour();

  int menit=now.minute();

  display.showNumberDecEx(menit,0,true,2,2);

  display.showNumberDecEx(jam,0x40,true,2,0);

  delay(500);

  display.showNumberDecEx(jam,0,true,2,0); 

  delay(500);

  

}



* library TM1637 : 

  https://github.com/avishorp/TM1637/


Video Youtube Channel :

https://www.youtube.com/channel/UCy9PYJmJXElN9LaHZw_PuTA











Friday, March 4, 2022

Setup Telegrambot long pooling method using php ( with menu keyboard )

<?php //Put Your telegrambot Toke in here define('TOKEN','5198830189:AAEY2XLkRWgkmmZR_EcRtDidKGQDFGESwetrgd'); //setting menu $line1 = array("MENU1","MENU2","MENU3"); $line2 = array("MENU4","MENU5","MENU6"); $line3 = array("MENU7","MENU8","MENU9"); $replyMarkup = array('keyboard' => array($line1,$line2,$line3),
"resize_keyboard" => true,"one_time_keyboard" => false); $encodedMarkup = json_encode($replyMarkup); //Function for send to api bot function Send2Bot($command){ return 'https://api.telegram.org/bot'.TOKEN.'/'.$command; } function SendData2Bot($command,$data){ $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents(Send2Bot($command), false, $context); return $result; } function SendCurl($command,$data){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,Send2Bot($command)); curl_setopt($ch, CURLOPT_POST, count($data)); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec ($ch); curl_close ($ch); return $result; } /* Function to get update from api bot use for long pooling method */ function GetUpdate($offset) { //send to Bot $url = Send2Bot("getUpdates")."?offset=".$offset; $result_send = file_get_contents($url); //Get result and json decode $result_json = json_decode($result_send, true); if ($result_json["ok"]==1) { return $result_json["result"]; } else { return array(); } } function RunningBot() { global $encodedMarkup; $update_id = 0; //start with offset =0, offset set to file //cek if there any file "belajarbot.last_update_id" if (file_exists("belajarbot.last_update_id")) { //if exist, read offsset $update_id = (int)file_get_contents("belajarbot.last_update_id"); } //get new update from ap bot $updates = GetUpdate($update_id); foreach ($updates as $message) { $receiveOK=false; // var_dump($message); $update_id = $message["update_id"];; $message_data = $message["message"]; //jika terdapat text dari Pengirim if (isset($message_data["text"])) { $receiveOK=true; $chatid = $message_data["chat"]["id"]; $message_id = $message_data["message_id"]; $text = $message_data["text"]; $data = array( 'chat_id' => $chatid, 'text' => 'You write message: ' . $text, 'parse_mode' => 'Markdown', 'reply_to_message_id' => $message_id ); //ada menu $data['reply_markup'] =$encodedMarkup; //send message to api bot using curl SendCurl('sendMessage',$data); } //update offset if ($receiveOK){ file_put_contents("belajarbot.last_update_id", $update_id + 1); } } } //Main Program while(true){ sleep(5); //delay 5 second RunningBot(); }



Sunday, February 13, 2022

PEMBUATAN JAM DIGITAL P10 MENGGUNAKAN Arduino nano & RTC 3231







ARDUINO PROGRAM


 /* JUDUL : PROGRAM JAM DIGITAL P10 1 PANEL DENGAN NANO & RTC 3231

 * COPY RIGHT : BELAJAR TEHNOLOGI JAMAN NOW

 * PUBLISH : 13 FEB 2022

 * EMAIL   : aplikasihebatstudio@gmail.com

 * 

 * NANO - P10

 * ----------

 * PIN YANG DISAMBUNG

 * Arduino              P-10

 * D6          ->      A

 * D7          ->      B

 * D8          ->      SCLK

 * D9          ->      OE (ENABLE)

 * D11         ->      DATA

 * D13         ->      CLK

 * GND         ->      GND


RTC 3231

--------

 * GND        >>      Pin GND

 * VCC        >>      Pin 5V

 * SDA        >>      Pin SDA  (A4)

 * SCL        >>      Pin SCL (A5)

 * SQW        >>      tidak dihubungkan

 * 32K        >>      tidak dihubungkan


*/



#include <Wire.h> 

#include "RTClib.h" 

#include "DMD.h"        

#include "TimerOne.h"

#include "SystemFont5x7.h"


#define DISPLAYS_ACROSS 1

#define DISPLAYS_DOWN 1


/***** P10 DISPLAY SETTING ***********************************/

DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN);


RTC_DS3231 rtc;



 // int tahun;                                                                              

  byte jam;

  byte menit;                                                                                                                                                                    //| 

  byte detik;

  byte bulan; 

  byte tahun;

  byte hari;

  byte tgl;

  int k; int j;


 

 void drawText(int kolom,int baris,String text);

 char weekDay[][7] = {"Mingg" ,"Senin","Slasa","Rabu", "Kamis", "jumat", "Sabtu"}; // array hari, dihitung mulai dari senin, hari senin angka nya =0,


  

//byte detik1=0;

void ScanDMD()

{

  dmd.scanDisplayBySPI();

}




void setup()

{  

  Timer1.initialize( 4000 );   // I find the default 5000 gives a visible flicker    

  Timer1.attachInterrupt( ScanDMD );  

  dmd.selectFont(SystemFont5x7);

  dmd.clearScreen( true );

   Wire.begin();

   rtc.begin();

 // just datatime  

 //  rtc.adjust(DateTime(2022, 02, 13, 14, 50, 0));

 k=0;

 j=0;

}



void loop()

{

  tampil_jam_kecil_tgl(30);

}





void drawText(int kolom,int baris,String text)

{

int pj_text=text.length()+1;

char text_char[pj_text];

text.toCharArray(text_char,pj_text);

dmd.drawString(kolom,baris,text_char,pj_text,GRAPHICS_NORMAL);



void tampil_jam_kecil_tgl(int lama)

{

 // dmd.clearScreen(true);

//lama=60;


String hh,mm,ss;

for(int i=0;i<lama;i++)

{   

   DateTime now = rtc.now();

   jam= now.hour();

   menit=now.minute();

   detik=now.second();   

   tahun  =  now.year();

   bulan = now.month();

   tgl  =  now.day();

                                                                                

   hh=Konversi(jam);

   mm=Konversi(menit);

   ss=Konversi(detik);


dmd.selectFont(SystemFont5x7);


if(k%2==0)

{

drawText(1,0,hh+":"+mm);

//drawText(1,9,Konversi(tgl)+"/"+Konversi(bulan));

k++;

else {

drawText(1,0,hh+" "+mm);

k=0;

}


j++;

if(j==1)

{

drawText(1,9,Konversi(tgl)+"/"+Konversi(bulan));


if(j==10)

{

drawText(1,9,String(weekDay[hari]));


}


if (j>=20) j=0;

delay(1000);



}


}



///Konversi angka agar ada nol didepannya jika diawah 10

String Konversi(int sInput) {

  if (sInput < 10)

  {

    return"0" + String(sInput);

  }

  else

  {

    return String(sInput);

  }

}



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