Displaying Telegram Message on Dot Matrix Using Arduino

Just modify ESP8266 program from previous tutorial, now you can display Telegram message on dot matrix using Arduino.

INTRODUCTION

In previous tutorial, we have show you how to program ESP WiFi Shield using Maker UNO. Just modify the program for ESP WiFi Shield, now you can display your Telegram message on dot matrix!

You may need to refer to Displaying Text Message on Dot Matrix Using Blynk and Arduino first, and all tutorials related to it.

VIDEO

This video shows how to display Telegram message on dot matrix using Arduino.

Untuk Bahasa Melayu, sila rujuk video dibawah.

HARDWARE PREPARATION

Sample Code

This is sample code used in the video. 1st code (top) is for ESP8266 WiFi Shield and the 2nd code (bottom) is for Maker UNO. Please replace your Telegram Bot token, WiFi SSID and password.

#include "CTBot.h"
CTBot myBot;
String ssid = "Your WiFi SSID";
String pass = "Your WiFi Password";
String token = "Your Telegram Bot Token";
void setup()
{
Serial.begin(9600);
myBot.wifiConnect(ssid, pass);
myBot.setTelegramToken(token);
delay(5000);
// Check if all things are ok
if (myBot.testConnection()) {
Serial.print("Telegram Bot Ready\n");
}
else {
Serial.print("Connection problem\n");
}
}
void loop()
{
TBMessage msg;
// If there is an incoming message...
if (myBot.getNewMessage(msg)) {
if (msg.text == "/start") {
Serial.print("Client ");
Serial.print(msg.sender.id);
Serial.write('\n');
myBot.sendMessage(msg.sender.id, "Welcome to Idris Bot.");
}
else {
Serial.print(msg.text);
Serial.write('\n');
myBot.sendMessage(msg.sender.id, "Text received.");
}
}
delay(500);
}
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <SoftwareSerial.h>
SoftwareSerial blynkSerial(2, 3);
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
#define NOTE_G4 392
#define NOTE_B4 494
#define BUZZER 8
int melody[] = {NOTE_B4, NOTE_G4};
int noteDurations[] = {8, 8};
// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Scrolling parameters
uint8_t scrollSpeed = 25; // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 2000; // in milliseconds
// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE 75
char curMessage[BUF_SIZE] = { "" };
char newMessage[BUF_SIZE] = { "Cytron Technologies" };
bool newMessageAvailable = true;
void readSerial(void)
{
static char *cp = newMessage;
while (blynkSerial.available()) {
*cp = (char)blynkSerial.read();
if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE - 2)) { // end of message character or full buffer
*cp = '\0'; // end the string
// restart the index for next filling spree and flag we have a message waiting
cp = newMessage;
newMessageAvailable = true;
}
else // move char pointer to next position
cp++;
}
}
void setup()
{
Serial.begin(9600);
Serial.print("\n[Parola Scrolling Display]\nType a message for the scrolling display\nEnd message line with a newline");
blynkSerial.begin(9600);
P.begin();
P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}
void loop()
{
if (P.displayAnimate()) {
if (newMessageAvailable) {
beep();
strcpy(curMessage, newMessage);
newMessageAvailable = false;
}
P.displayReset();
}
readSerial();
}
void beep()
{
for (int thisNote = 0; thisNote < 2; thisNote++) {
int noteDuration = 1000 / noteDurations[thisNote];
tone(BUZZER, melody[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(BUZZER);
}
}

Thank You

References:

  1. Displaying on MAX7219 Dot Matrix Using Arduino
  2. Displaying Text Message on Dot Matrix Using Blynk App and Arduino
  3. Displaying Telegram Message on Dot Matrix Using Raspberry Pi 

Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.

 

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
Tutorials of Cytron Technologies Scroll to Top