Skip to content

Instantly share code, notes, and snippets.

@IdrisCytron
Last active January 29, 2019 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IdrisCytron/cf4a10823755355285d37a2baec9717d to your computer and use it in GitHub Desktop.
Save IdrisCytron/cf4a10823755355285d37a2baec9717d to your computer and use it in GitHub Desktop.
Displaying text on dot matrix through Blynk app using Arduino platform (Maker UNO + ESP WiFi Shield).
/* Comment this out to disable prints and save space */
//#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "BlynkAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourWiFiSSID";
char pass[] = "YourWiFiPass";
BLYNK_WRITE(V0)
{
String textIn = param.asStr();
Serial.print(textIn + "\n");
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
delay(5000);
Serial.print("Blynk Ready\n");
}
void loop()
{
Blynk.run();
}
#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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment