Running Text Max7219 Arduino Bluetooth



Tutorial Merakit dan menggunakan.




Program Utama

=================================Source Code================================

#include "MD_Parola.h"
#include "MD_MAX72xx.h"
#include "SPI.h"


#define MAX_DEVICES 8
#define CLK_PIN  13
#define DATA_PIN 11
#define CS_PIN  10


#define USE_UI_CONTROL 1

#if USE_UI_CONTROL
#define SPEED_IN A5
uint8_t frameDelay = 25; 
#endif


MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

#define SPEED_TIME 100
#define PAUSE_TIME 1000


#define  DEBUG  0

#if  DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif

bool firsttime = true;
char c;
void Write(char *tulisan);
String stringOne;
char charBuf[200];


uint8_t  curText;
char *pc[] =
{
  ""
};

uint8_t  inFX, outFX;
textEffect_t effect[] =
{
  PA_SCROLL_LEFT
};

#if USE_UI_CONTROL
void doUI(void)
{
  // set the speed if it has changed
  {
    int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 0, 250);

    if (speed != (int16_t)P.getSpeed())
    {


      int speed1 = 40;        
      P.setSpeed(speed1);     
      P.setPause(speed1);     
      frameDelay = speed1;    
      
      PRINT("\nChanged speed to ", P.getSpeed());
    }
  }
}
#endif 

char* string2char(String command){
    if(command.length()!=0){
        char *p = const_cast(command.c_str());
        return p;
    }
}


void setup(void)
{

#if USE_UI_CONTROL
  pinMode(SPEED_IN, INPUT);
  doUI();
#endif 
  P.begin();
  P.setInvert(false);
  P.displayText(pc[curText], PA_CENTER, SPEED_TIME, PAUSE_TIME, effect[inFX], effect[outFX]);

  Serial.begin(9600);
  Serial.println("Mula");

}

void loop()
{

  while (Serial.available()) 
  {
         
    if (Serial.available() > 0) 
    {
      firsttime = false;
      stringOne = Serial.readString();
      Serial.println(stringOne);
                 
      stringOne.toCharArray(charBuf, 200) ;
    }

 
    Serial.flush();  
  }
  
if (firsttime == false) Write(charBuf);
else Write("Welcome!");
      
}


void Write(char *tulisan)
{
  
#if USE_UI_CONTROL
 doUI();
#endif 

char *pc[] = {tulisan};

  if (P.displayAnimate()) 
  {
    
    curText = (++curText);
    P.setTextBuffer(pc[curText]);
    
  
    if (curText == 0)
    {
      outFX = (++outFX);
      if (outFX == 0)
      {
        inFX = (++inFX);
        if (inFX == 0)
          P.setInvert(!P.getInvert());
      }

      P.setTextEffect(effect[inFX], effect[outFX]);
    }

  
    P.displayReset();
  }
}






Aplikasi Untuk Android BT Terminal

*Project Ini Merupakan pesanan dari TOKOTRONIK

No comments

Dicky B_Mz. Powered by Blogger.