Tuesday 8 April 2014

Arduino LCD - Scrolling Text on a Large Display

Very exciting today - our large led matrix display arrived...
After initial problems with the Arduino Ide not synching correctly with my laptop we managed to get the laptop to see the Arduino on the correct COM port. We hope to get Arduino IDE across all the computers in Technology eventually.


We got started setting it up. It came with an instruction sheet which was very helpful in getting it up and running.





Connecting the board with an Arduino Uno proved to be pretty easy. Just connect the supplied ribbon cable the correct way around an its all linked up. Power is taken from the Arduino board itself, so convenient but can also be made brighter with the addition of an external power supply at 5V.


Getting the libraries into the Arduino IDE was pretty easy too.


A guide is available for you to see...
http://cdn.shopify.com/s/files/1/0045/8932/files/DMD_Getting_Started.pdf?100647


Once the libraries were installed into the correct place, we fired up a couple of example files to see what we would be able to do.


Scrolling text to announce sports results was what we really wanted, so we looked at thje code and made a few modifications...




 To do so, have your sketch first assemble the text to display into a String variable. The maximum length is 255 characters. Or you can just have a fixed value, for example:
String textToScroll = "Hello, this is a really long length of text";
You will also need the following function in your sketch:
void drawText(String dispString) 
{
  dmd.clearScreen( true );
  dmd.selectFont( Arial_Black_16 );
  char newString[256];
  int sLength = dispString.length();
  dispString.toCharArray( newString, sLength+1 );
  dmd.drawMarquee(newString,sLength,( 32*DISPLAYS_ACROSS )-1 , 0 );
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ( ( timer+20 ) < millis() ) {
      ret=dmd.stepMarquee( -1 , 0 );
      timer=millis();
    }
  }
}
Then to scroll the text, simply call the function as required, for example:
drawText(textToScroll);
The following is the total sketch for a basic text-scrolling application using the function from above:
#include "SPI.h"        
#include "DMD.h"        
#include "TimerOne.h"
#include "Arial_black_16.h" 
/* you can remove the fonts if unused */
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN );

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

void setup()
{
   Timer1.initialize( 5000 );           
   Timer1.attachInterrupt( ScanDMD );  
   dmd.clearScreen( true );            
}

String textToScroll="Hello, this will be displayed on the DMD";

void drawText( String dispString ) 
{
  dmd.clearScreen( true );
  dmd.selectFont( Arial_Black_16 );
  char newString[256];
  int sLength = dispString.length();
  dispString.toCharArray( newString, sLength+1 );
  dmd.drawMarquee( newString , sLength , ( 32*DISPLAYS_ACROSS )-1 ,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while( !ret ){
    if ( ( timer+20 ) < millis() ) {
      ret=dmd.stepMarquee( -1 , 0 );
      timer=millis();
    }
  }
}

void loop()
{
  drawText(textToScroll);
}






Arduino Libraries are kept on github here...
https://github.com/freetronics/DMD


Brodie managed to get the text to scroll across the screen and also managed to change the speed which is cool. We are still not certain that the average user would be able to get text onto this easily, as it requires code-level operation. The best scenario would be to be able to send text to the internet somehow, then for the 'net connected board to simply display it.













Thursday 3 April 2014

Arduino LCD


After Mr Jagoutz asked me if I would like to help him [build]  a project of his -An LCD display that could be hung in the school office window and used to display school news/temperature/sports results - I was excited, because working with a teacher presented me with a unique opportunity to learn from [Mr Jagoutz] as we worked.

After some research I found a large LED matrix display⁴ from JayCar with a build in controller that was Arduino  compatible.

We (Myself & Mr Jagoutz) decided that before we committed to buying the display, we would try to do something similar but with one of the schools small 16x2 LCD displays⁵.

The following is the result of the above endevour:



While in activities on Wednesday afternoon I altered an example sketch I had gotten from the LCD shield manufacturers website⁷, This is the "Hello Mr Jag, It's working" examples. I ask if I could borrow the LCD shield, and once I got home, booted into Ubuntu and started coding. I wrote my own sketch from scratch - the flashing "Hello World".  And then altered one of the example sketches (Examples>LiquidCrystal>SerialDisplay) to send text to the Arduino.

 jaycar.co.nz/productView.asp?ID=XC4250&w=dot+matrix+display&form=KEYWORD
www.dfrobot.com/index.php?route=product/product&product_id=51
www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)