Scrolling sine wave

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
Faziphil
Posts:2
Joined:Sat Nov 16, 2013 6:19 am
Scrolling sine wave

Post by Faziphil » Sat Dec 14, 2013 1:26 pm

Here's a small sketch for a scrolling sine wave.

Code: Select all

// DMD sinewave sketch
// Author - Phil Tregillis

#include <SPI.h> 
#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);

int dlyTime;
float angRad=0.0;
int xPos;
int yPos;


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


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


void loop(void)
{

  for( xPos = 0; xPos < 32; xPos ++ ) {
    yPos = (sin(angRad*6.284)*8.0) + 7;
    dmd.writePixel( xPos, yPos, GRAPHICS_NORMAL, 1 );
    angRad = angRad + 0.06;
  }
  delay(50);
  dmd.clearScreen( true);
}

andrew
Freetronics Staff
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

Re: Scrolling sine wave

Post by andrew » Sun Dec 15, 2013 4:06 am

Awesome, thanks for that :)

Post Reply