Membuat running text 1 dan 2 baris denga led P10 menggunakan Arduino Wemos d1 mini
Untuk membuat membuat running text dengan LED menggunakan arduino wemows d1 diperlukan bahan sebagai berikut:
1. Arduino Wemos d1 mini
2. Led P10 + kabel konektor p10
3. Kabel usb micro
4. Arduino IDE Editor
Rangkaian Lengkap
Pin di P10
Skema Rangkaian
Pin P10 ke Arduino Wemos
Pin 1(Enable) ----> D4
Pin 2 (A) ----> D0
Pin 4 (B) ----> D6
Pin8 ( CLK) ----> D5
Pin 10 (SCLK) ----> D3
Pin 12 (DATA) ----> D7
Program Arduino
_20210207-running_text_2baris_and_running_besar_wemosp10.ino
#include <Wire.h>
#include "RTClib.h"
#include <SPI.h>
#include <DMD2.h>
#include <fonts/SystemFont5x7.h>
#include <fonts/Arial_Black_16.h>
#include <fonts/Droid_Sans_12.h>
#include <fonts/Droid_Sans_16.h>
void Running(String s);
String Konversi(int sInput);
void jam_besar(int lama);
// Set Width to the number of displays wide you have
const int WIDTH = 2;
// You can change to a smaller font (two lines) by commenting this line,
// and uncommenting the line after it:
const uint8_t *FONT = Arial_Black_16;
const uint8_t *FONT2 = Droid_Sans_12;
const uint8_t *FONT3 =Droid_Sans_16;
const uint8_t *FONT4 = SystemFont5x7;
SPIDMD dmd(2, 1, D4,D0,D6,D3);
//// marquee values
int marX = 1; // awal kotak running text minimal diawali 1.
int marY = 1;
int marWidth = 63; // dimensi running text 32 dikurangi marX.
int marHeight = 16;
int marCur = marX + marWidth; // kursor
//marCur = marX + marWidth;
int messageCount; // karakter yang aktif
//int widthCount; // sisa lebar satu huruf terakhir
int messageLength; // jumlah karakter pada pesan
boolean blinking=true;
int i=0;
boolean jalan=true;
int hours, minutes; //jam sholat dan menit sholat
// double times[sizeof(TimeName) / sizeof(char*)];
void Running_besar(String s);
int tulisan_menuju_azan(int jam,int menit,String* waktu_sholat);
// the setup routine runs once when you press reset:
void setup() {
pinMode(D4,OUTPUT);
digitalWrite(D4,LOW);
dmd.setBrightness(250);
dmd.begin();
dmd.selectFont(SystemFont5x7);
dmd.clearScreen();
}
void loop()
{
dmd.clearScreen();
int lama=1; //3 menit
for(i=0;i<2*lama;i++)
{
Running("SELAMAT DATANG DI WORKSHOP KAMI");
}
dmd.clearScreen();
lama=1; //3 menit
for(i=0;i<2*lama;i++)
{
Running_besar("SELAMAT DATANG DI WORKSHOP KAMI");
}
jam_besar(30);
}
void Running(String s)
{
int jam= 10;
int menit=10;
int detik=10;
String waktu1=Konversi(jam)+":"+Konversi(menit)+" ";
dmd.selectFont(SystemFont5x7);
dmd.drawString(33,0,waktu1);
marX=1;
marY=9;
jalan=true;
while(jalan)
{
messageLength = s.length()+65;
//Geser 1 pixel dulu.
dmd.movePixels(marX, marY, marX-1, marY, marWidth, marHeight);
marCur = marCur-1;
if (marCur == marX + marWidth - dmd.charWidth(s[messageCount],FONT)-1) {
marCur = marX + marWidth;
messageCount = messageCount+1;
if (messageCount == messageLength){
messageCount = 0;
jalan=false;
}
}
dmd.selectFont(SystemFont5x7);
dmd.drawChar(marCur, marY , s[messageCount]); // tulis karakter baru setelah digeser
delay(50);
i++;
if(i*50 >600)
{
// DateTime now = rtc.now();
int jam= 10;
int menit=10;
int detik=10;
String waktu1=Konversi(jam)+":"+Konversi(menit)+" ";
String waktu2=Konversi(jam)+" "+Konversi(menit)+" ";
if (blinking)
{
dmd.selectFont(SystemFont5x7);
dmd.drawString(33,0,waktu1);
blinking=false;
}
else
{
dmd.selectFont(SystemFont5x7);
dmd.drawString(33,0,waktu2);
blinking=true;
}
i=0;
}
}
}
///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 jam_besar(int lama)
{
dmd.clearScreen();
for (int i=0;i<=lama;i++)
{
int jam= 22;//now.hour();
int menit=10;//now.minute();
int detik=0;//now.second();
String waktu1=Konversi(jam)+":"+Konversi(menit)+" ";
String waktu2=Konversi(jam)+" "+Konversi(menit)+" ";
dmd.selectFont(Droid_Sans_12);
dmd.drawString(34, 3, Konversi(jam)); //koordinat tampilan
dmd.drawString(46, 2, "::"); //koordinat tampilan
dmd.drawString(51, 3, Konversi(menit)+" ");
delay(500);
dmd.drawString(34, 3, Konversi(jam)); //koordinat tampilan
dmd.drawString(46, 2, " "); //koordinat tampilan
dmd.drawString(51, 3, Konversi(menit)+" ");
delay(500);
}
dmd.clearScreen();
}
void Running_besar(String s)
{
dmd.selectFont(Droid_Sans_12);
marX=1;
marY=4;
//DMDFrame subFrame(35, 1, 60, 14);
jalan=true;
while(jalan)
{
messageLength = s.length()+65;
//Geser 1 pixel dulu.
dmd.movePixels(marX, marY, marX-1, marY, marWidth, marHeight);
marCur = marCur-1;
if (marCur == marX + marWidth - dmd.charWidth(s[messageCount],FONT)-1) {
marCur = marX + marWidth;
messageCount = messageCount+1;
if (messageCount == messageLength){
messageCount = 0;
jalan=false;
}
}
dmd.drawChar(marCur, marY , s[messageCount]); // tulis karakter baru setelah digeser
delay(40);
}
}