API ARDUINO

LED Display Board using P10 LED and Arduino

Required Components

  • Arduino UNO-1
  • 32*16 P10 LED display module-1
  • 16 Pin FRC connector-1
  • 5V DC,3 AMP SMPS
  • Connectors
#include <SPI.h>        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h>        //
#include <TimerOne.h>   //
#include "SystemFont5x7.h"
#include "Arial_black_16.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

String serial_data = "0";
char token[5] = "00000";
/*--------------------------------------------------------------------------------------
  Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
  called at the period set in Timer1.initialize();
--------------------------------------------------------------------------------------*/

void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
  setup
  Called by the Arduino architecture before the main loop begins
--------------------------------------------------------------------------------------*/
void setup(void)
{
  Serial.begin(9600);

   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
   //Timer1.initialize( 2000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
   Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
   
   //clear/init the DMD pixels held in RAM
   dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)

}

/*--------------------------------------------------------------------------------------
  loop
  Arduino architecture main loop
--------------------------------------------------------------------------------------*/
void loop()
{
   

  
   char title[] = "TOKEN";
   
   
   dmd.clearScreen( true );
   dmd.selectFont(System5x7);
   dmd.drawString( 2, 0, title, 5, GRAPHICS_NORMAL);
   dmd.drawString( 2, 9, token, 5, GRAPHICS_NORMAL);
   delay(1000);

   while (Serial.available() == 0) {}     //wait for data available
   serial_data = Serial.readString();  //read until timeout
   serial_data.trim();
   
    for (int i = 0; i < serial_data.length(); i++) { 
        token[i] = serial_data[i]; 
    } 
   
}