Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Voidrealms Facebook for attention of Bryan Cairns*/
- #include <MD_Parola.h>
- #include <MD_MAX72xx.h>
- #include <SPI.h>
- #define BUF_SIZE 100
- #define HARDWARE_TYPE MD_MAX72XX::FC16_HW /*< --- This is the hardware desription */
- #define MAX_DEVICES 4
- #define PAUSE_TIME 4000
- #define CLK_PIN 13
- #define DATA_PIN 11
- #define CS_PIN 10
- // Global variables
- // HARDWARE SPI
- MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
- char newMessage[BUF_SIZE] = { "Are you Ready ? Enter new message " };
- bool msgReady = false ;
- uint8_t scrollSpeed = 50; // default frame delay value
- textEffect_t scrollEffect = PA_SCROLL_LEFT;
- textPosition_t scrollAlign = PA_LEFT;
- uint16_t scrollPause = 2000; // in milliseconds
- char *pChar = newMessage; // this is a pointer declaration
- bool printOnce = false ;
- void setup() {
- Serial.begin(57600);
- delay(500) ;
- P.begin();
- P.displayText(newMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
- }
- void readSerialPort(void)
- {
- while (Serial.available())
- {
- // read first byte or first character
- *pChar = (char)Serial.read();
- // Check for newline
- if ((*pChar == '\n') || (pChar - newMessage >= BUF_SIZE-2)) // end of message character or full buffer
- {
- *pChar = '\0'; // end the string
- // restart the index for next filling spree and flag we have a message waiting
- pChar = newMessage;
- msgReady = true;
- }
- else // move char pointer to next position
- pChar++;
- }
- if(printOnce)
- {
- Serial.flush();
- Serial.println(newMessage) ;
- printOnce = false ;
- }
- }
- void loop() {
- if (P.displayAnimate())
- {
- if (msgReady)
- {
- printOnce =true ;
- msgReady = false;
- }
- P.displayReset();
- }
- readSerialPort();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement