new to DMD

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
colandra
Posts: 4
Joined: Wed Apr 17, 2013 8:26 am

new to DMD

Post by colandra » Wed Apr 17, 2013 8:43 am

I am very new to the world of arduino and DMD units. I have purchased a DMD and someone has provided an Arduino board on loan, due to mt tight time frame.

I need some assistance in getting started.

I have followed the basic tutorials for the Arduino and the DMD and have had success with each project. Of course some else has done all the hard work.

Now it is time to move forward.

My project is basic, I believe, all I wish to do is have a button connected to a digital input on the Arduino. Each time the button changes state off - on - off the Arduino registers a one count, and increments the stored count value by one each time the button cycle occurrs. I then want to display this incrementing value on the DMD. I require a second button to a second digital input to reset the stored incremented value in the Arduino to zero when pressed.

The button frequency of operation is very slow, so I do not think there will be clock issues.

I believe a sample program I found, referred to " the change of state button " is a good starting point. But not sure.

Have a bit of a time shortage on the base program as it is to do with my childrens pre-school for teaching counting. I will then use the base program to learn and expand my knowledge as time permits.

Could someone please provide a program to achieve this requirement, or point me to something similar.

Any assistance will be greatly appreciated.

Sorry for the basic enquiry.

Regards

Colandra

colandra
Posts: 4
Joined: Wed Apr 17, 2013 8:26 am

Re: new to DMD

Post by colandra » Thu Apr 18, 2013 2:08 pm

Thank you very much for your prompt response to my post. Greatly appreciated.

Gives we a good start.

Again thank you.

Colandra

colandra
Posts: 4
Joined: Wed Apr 17, 2013 8:26 am

Re: new to DMD

Post by colandra » Mon Apr 29, 2013 3:26 pm

Thank you very much for your previous assistance, much appreciated.

I have managed to get your sketch to run, learnt a bit along the way.

Have run into a bit of an issue, and it is a bit beyond me at this stage.

Some of the children who will be using this counter have learning difficulties. It was required that the clock was slowed, inturn slowing the digit appearing on the screen. Also, the count update was increased to make the count button less reactive. The children where not removing their little fingures quick enough.

I have increased the count max to 700, and the drawstring commanset to 413. However it will not allow me to go any higher. Odd led's start lighting up. The bit count is 20K plus out of 32K. I was wondering if there is something I am not aware of. Or is this a limitation. By the way I Purchased an Etherten, and switched from the arduino. Or should have I stuck with the Arduino in this instance.

Sketch as it stands is

Code: Select all

// DMDcountup.ino 18/04/2013 John Boxall. 
// HIGH on digital 2 increments number, 3 resets. 

#include <DMD.h> // for DMD
#include <SPI.h> // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
DMD dmd(1, 1); // creates instance of DMD to refer to in sketch


void ScanDMD() // necessary interrupt handler for refresh scanning of DMD
{ 
  dmd.scanDisplayBySPI();
}

void setup()
{
  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1110 );           //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()  
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  dmd.selectFont(Arial_Black_16);    
  drawNumber(0);
}

void drawNumber(int value)
{
  switch(value)
  {
  case 0:
    dmd.drawString( 7,1, "0", 1, GRAPHICS_NORMAL );
    break;
  case 1:
    dmd.drawString( 8,1, "1", 1, GRAPHICS_NORMAL );
    break;
  case 2:
    dmd.drawString( 7,1, "2", 1, GRAPHICS_NORMAL );
    break;
  case 3:
    dmd.drawString( 7,1, "3", 1, GRAPHICS_NORMAL );
    break;
  case 4:
    dmd.drawString( 7,1, "4", 1, GRAPHICS_NORMAL );
    break;
  case 5:
    dmd.drawString( 7,1, "5", 1, GRAPHICS_NORMAL );
    break;
  case 6:
    dmd.drawString( 7,1, "6", 1, GRAPHICS_NORMAL );
    break;
  case 7:
    dmd.drawString( 7,1, "7", 1, GRAPHICS_NORMAL );
    break;
  case 8:
    dmd.drawString( 7,1, "8", 1, GRAPHICS_NORMAL );
    break;
  case 9:
    dmd.drawString( 7,1, "9", 1, GRAPHICS_NORMAL );
    break;
  case 10:
    dmd.drawString( 8,1, "10", 2, GRAPHICS_NORMAL );
    break;
  case 11:
    dmd.drawString( 9,1, "11", 2, GRAPHICS_NORMAL );
    break;
  case 12:
    dmd.drawString( 8,1, "12", 2, GRAPHICS_NORMAL );
    break;
  case 13:
    dmd.drawString( 8,1, "13", 2, GRAPHICS_NORMAL );
    break;
  case 14:
    dmd.drawString( 8,1, "14", 2, GRAPHICS_NORMAL );
    break;
  case 15:
    dmd.drawString( 8,1, "15", 2, GRAPHICS_NORMAL );
    break;
  case 16:
    dmd.drawString( 8,1, "16", 2, GRAPHICS_NORMAL );
    break;
  case 17:
    dmd.drawString( 8,1, "17", 2, GRAPHICS_NORMAL );
    break;
  case 18:
    dmd.drawString( 8,1, "18", 2, GRAPHICS_NORMAL );
    break;
  case 19:
    dmd.drawString( 8,1, "19", 2, GRAPHICS_NORMAL );
    break;
  case 20:
    dmd.drawString( 7,1, "20", 2, GRAPHICS_NORMAL );
    break;
  case 21:
    dmd.drawString( 8,1, "21", 2, GRAPHICS_NORMAL );
    break;
  case 22:
    dmd.drawString( 7,1, "22", 2, GRAPHICS_NORMAL );
    break;
  case 23:
    dmd.drawString( 7,1, "23", 2, GRAPHICS_NORMAL );
    break;
  case 24:
    dmd.drawString( 7,1, "24", 2, GRAPHICS_NORMAL );
    break;
  case 25:
    dmd.drawString( 7,1, "25", 2, GRAPHICS_NORMAL );
    break;
  case 26:
    dmd.drawString( 7,1, "26", 2, GRAPHICS_NORMAL );
    break;
  case 27:
    dmd.drawString( 7,1, "27", 2, GRAPHICS_NORMAL );
    break;
  case 28:
    dmd.drawString( 7,1, "28", 2, GRAPHICS_NORMAL );
    break;
  case 29:
    dmd.drawString( 7,1, "29", 2, GRAPHICS_NORMAL );
    break;
  case 30:
    dmd.drawString( 7,1, "30", 2, GRAPHICS_NORMAL );
    break;
  case 31:
    dmd.drawString( 8,1, "31", 2, GRAPHICS_NORMAL );
    break;
  case 32:
    dmd.drawString( 7,1, "32", 2, GRAPHICS_NORMAL );
    break;
  case 33:
    dmd.drawString( 7,1, "33", 2, GRAPHICS_NORMAL );
    break;
  case 34:
    dmd.drawString( 7,1, "34", 2, GRAPHICS_NORMAL );
    break;
  case 35:
    dmd.drawString( 7,1, "35", 2, GRAPHICS_NORMAL );
    break;
  case 36:
    dmd.drawString( 7,1, "36", 2, GRAPHICS_NORMAL );
    break;
  case 37:
    dmd.drawString( 7,1, "37", 2, GRAPHICS_NORMAL );
    break;
  case 38:
    dmd.drawString( 7,1, "38", 2, GRAPHICS_NORMAL );
    break;
  case 39:
    dmd.drawString( 7,1, "39", 2, GRAPHICS_NORMAL );
    break;
  case 40:
    dmd.drawString( 7,1, "40", 2, GRAPHICS_NORMAL );
    break;
  case 41:
    dmd.drawString( 8,1, "41", 2, GRAPHICS_NORMAL );
    break;
  case 42:
    dmd.drawString( 7,1, "42", 2, GRAPHICS_NORMAL );
    break;
  case 43:
    dmd.drawString( 7,1, "43", 2, GRAPHICS_NORMAL );
    break;
  case 44:
    dmd.drawString( 7,1, "44", 2, GRAPHICS_NORMAL );
    break;
  case 45:
    dmd.drawString( 7,1, "45", 2, GRAPHICS_NORMAL );
    break;
  case 46:
    dmd.drawString( 7,1, "46", 2, GRAPHICS_NORMAL );
    break;
  case 47:
    dmd.drawString( 7,1, "47", 2, GRAPHICS_NORMAL );
    break;
  case 48:
    dmd.drawString( 7,1, "48", 2, GRAPHICS_NORMAL );
    break;
  case 49:
    dmd.drawString( 7,1, "49", 2, GRAPHICS_NORMAL );
    break;
  case 50:
    dmd.drawString( 7,1, "50", 2, GRAPHICS_NORMAL );
    break;
  case 51:
    dmd.drawString( 8,1, "51", 2, GRAPHICS_NORMAL );
    break;
  case 52:
    dmd.drawString( 7,1, "52", 2, GRAPHICS_NORMAL );
    break;
  case 53:
    dmd.drawString( 7,1, "53", 2, GRAPHICS_NORMAL );
    break;
  case 54:
    dmd.drawString( 7,1, "54", 2, GRAPHICS_NORMAL );
    break;
  case 55:
    dmd.drawString( 7,1, "55", 2, GRAPHICS_NORMAL );
    break;
  case 56:
    dmd.drawString( 7,1, "56", 2, GRAPHICS_NORMAL );
    break;
  case 57:
    dmd.drawString( 7,1, "57", 2, GRAPHICS_NORMAL );
    break;
  case 58:
    dmd.drawString( 7,1, "58", 2, GRAPHICS_NORMAL );
    break;
  case 59:
    dmd.drawString( 7,1, "59", 2, GRAPHICS_NORMAL );
    break;
  case 60:
    dmd.drawString( 7,1, "60", 2, GRAPHICS_NORMAL );
    break;
  case 61:
    dmd.drawString( 8,1, "61", 2, GRAPHICS_NORMAL );
    break;
  case 62:
    dmd.drawString( 7,1, "62", 2, GRAPHICS_NORMAL );
    break;
  case 63:
    dmd.drawString( 7,1, "63", 2, GRAPHICS_NORMAL );
    break;
  case 64:
    dmd.drawString( 7,1, "64", 2, GRAPHICS_NORMAL );
    break;
  case 65:
    dmd.drawString( 7,1, "65", 2, GRAPHICS_NORMAL );
    break;
  case 66:
    dmd.drawString( 7,1, "66", 2, GRAPHICS_NORMAL );
    break;
  case 67:
    dmd.drawString( 7,1, "67", 2, GRAPHICS_NORMAL );
    break;
  case 68:
    dmd.drawString( 7,1, "68", 2, GRAPHICS_NORMAL );
    break;
  case 69:
    dmd.drawString( 7,1, "69", 2, GRAPHICS_NORMAL );
    break;
  case 70:
    dmd.drawString( 7,1, "70", 2, GRAPHICS_NORMAL );
    break;
  case 71:
    dmd.drawString( 8,1, "71", 2, GRAPHICS_NORMAL );
    break;
  case 72:
    dmd.drawString( 7,1, "72", 2, GRAPHICS_NORMAL );
    break;
  case 73:
    dmd.drawString( 7,1, "73", 2, GRAPHICS_NORMAL );
    break;
  case 74:
    dmd.drawString( 7,1, "74", 2, GRAPHICS_NORMAL );
    break;
  case 75:
    dmd.drawString( 7,1, "75", 2, GRAPHICS_NORMAL );
    break;
  case 76:
    dmd.drawString( 7,1, "76", 2, GRAPHICS_NORMAL );
    break;
  case 77:
    dmd.drawString( 7,1, "77", 2, GRAPHICS_NORMAL );
    break;
  case 78:
    dmd.drawString( 7,1, "78", 2, GRAPHICS_NORMAL );
    break;  
  case 79:
    dmd.drawString( 7,1, "79", 2, GRAPHICS_NORMAL );
    break;
  case 80:
    dmd.drawString( 7,1, "80", 2, GRAPHICS_NORMAL );
    break;
  case 81:
    dmd.drawString( 8,1, "81", 2, GRAPHICS_NORMAL );
    break;
  case 82:
    dmd.drawString( 7,1, "82", 2, GRAPHICS_NORMAL );
    break;
  case 83:
    dmd.drawString( 7,1, "83", 2, GRAPHICS_NORMAL );
    break;
  case 84:
    dmd.drawString( 7,1, "84", 2, GRAPHICS_NORMAL );
    break;
  case 85:
    dmd.drawString( 7,1, "85", 2, GRAPHICS_NORMAL );
    break;
  case 86:
    dmd.drawString( 7,1, "86", 2, GRAPHICS_NORMAL );
    break;
  case 87:
    dmd.drawString( 7,1, "87", 2, GRAPHICS_NORMAL );
    break;
  case 88:
    dmd.drawString( 7,1, "88", 2, GRAPHICS_NORMAL );
    break;
  case 89:
    dmd.drawString( 7,1, "89", 2, GRAPHICS_NORMAL );
    break;
  case 90:
    dmd.drawString( 7,1, "90", 2, GRAPHICS_NORMAL );
    break;
  case 91:
    dmd.drawString( 8,1, "91", 2, GRAPHICS_NORMAL );
    break;
  case 92:
    dmd.drawString( 7,1, "92", 2, GRAPHICS_NORMAL );
    break;
  case 93:
    dmd.drawString( 7,1, "93", 2, GRAPHICS_NORMAL );
    break;
  case 94:
    dmd.drawString( 7,1, "94", 2, GRAPHICS_NORMAL );
    break;
  case 95:
    dmd.drawString( 7,1, "95", 2, GRAPHICS_NORMAL );
    break;
  case 96:
    dmd.drawString( 7,1, "96", 2, GRAPHICS_NORMAL );
    break;
  case 97:
    dmd.drawString( 7,1, "97", 2, GRAPHICS_NORMAL );
    break;
  case 98:
    dmd.drawString( 7,1, "98", 2, GRAPHICS_NORMAL );
    break;
  case 99:
    dmd.drawString( 7,1, "99", 2, GRAPHICS_NORMAL );  
    break;
  case 100:
    dmd.drawString( 6,1, "100", 3, GRAPHICS_NORMAL );  
    break;
  case 101:
    dmd.drawString( 7,1, "101", 3, GRAPHICS_NORMAL );  
    break;
  case 102:
    dmd.drawString( 7,1, "102", 3, GRAPHICS_NORMAL );  
    break;
  case 103:
    dmd.drawString( 7,1, "103", 3, GRAPHICS_NORMAL );  
    break;
  case 104:
    dmd.drawString( 6,1, "104", 3, GRAPHICS_NORMAL );  
    break;
  case 105:
    dmd.drawString( 7,1, "105", 3, GRAPHICS_NORMAL );  
    break;
  case 106:
    dmd.drawString( 7,1, "106", 3, GRAPHICS_NORMAL );  
    break;
  case 107:
    dmd.drawString( 7,1, "107", 3, GRAPHICS_NORMAL );  
    break;
  case 108:
    dmd.drawString( 7,1, "108", 3, GRAPHICS_NORMAL );  
    break;
  case 109:
    dmd.drawString( 7,1, "109", 3, GRAPHICS_NORMAL );  
    break;
  case 110:
    dmd.drawString( 8,1, "110", 3, GRAPHICS_NORMAL );  
    break;
  case 111:
    dmd.drawString( 9,1, "111", 3, GRAPHICS_NORMAL );  
    break;
  case 112:
    dmd.drawString( 8,1, "112", 3, GRAPHICS_NORMAL );  
    break;
  case 113:
    dmd.drawString( 8,1, "113", 3, GRAPHICS_NORMAL );  
    break;
  case 114:
    dmd.drawString( 8,1, "114", 3, GRAPHICS_NORMAL );  
    break;
  case 115:
    dmd.drawString( 8,1, "115", 3, GRAPHICS_NORMAL );  
    break;
  case 116:
    dmd.drawString( 8,1, "116", 3, GRAPHICS_NORMAL );  
    break;
  case 117:
    dmd.drawString( 8,1, "117", 3, GRAPHICS_NORMAL );  
    break;
  case 118:
    dmd.drawString( 8,1, "118", 3, GRAPHICS_NORMAL );  
    break;
  case 119:
    dmd.drawString( 8,1, "119", 3, GRAPHICS_NORMAL );  
    break;
  case 120:
    dmd.drawString( 7,1, "120", 3, GRAPHICS_NORMAL );  
    break;
  case 121:
    dmd.drawString( 8,1, "121", 3, GRAPHICS_NORMAL );  
    break;
  case 122:
    dmd.drawString( 7,1, "122", 3, GRAPHICS_NORMAL );  
    break;
  case 123:
    dmd.drawString( 7,1, "123", 3, GRAPHICS_NORMAL );  
    break;
  case 124:
    dmd.drawString( 6,1, "124", 3, GRAPHICS_NORMAL );  
    break;
  case 125:
    dmd.drawString( 7,1, "125", 3, GRAPHICS_NORMAL );  
    break;
  case 126:
    dmd.drawString( 7,1, "126", 3, GRAPHICS_NORMAL );  
    break;
  case 127:
    dmd.drawString( 7,1, "127", 3, GRAPHICS_NORMAL );  
    break;
  case 128:
    dmd.drawString( 7,1, "128", 3, GRAPHICS_NORMAL );  
    break;
  case 129:
    dmd.drawString( 7,1, "129", 3, GRAPHICS_NORMAL );  
    break;
  case 130:
    dmd.drawString( 7,1, "130", 3, GRAPHICS_NORMAL );  
    break;
  case 131:
    dmd.drawString( 8,1, "131", 3, GRAPHICS_NORMAL );  
    break;
  case 132:
    dmd.drawString( 7,1, "132", 3, GRAPHICS_NORMAL );  
    break;
  case 133:
    dmd.drawString( 7,1, "133", 3, GRAPHICS_NORMAL );  
    break;
  case 134:
    dmd.drawString( 6,1, "134", 3, GRAPHICS_NORMAL );  
    break;
  case 135:
    dmd.drawString( 7,1, "135", 3, GRAPHICS_NORMAL );  
    break;
  case 136:
    dmd.drawString( 7,1, "136", 3, GRAPHICS_NORMAL );  
    break;
  case 137:
    dmd.drawString( 7,1, "137", 3, GRAPHICS_NORMAL );  
    break;
  case 138:
    dmd.drawString( 7,1, "138", 3, GRAPHICS_NORMAL );  
    break;
  case 139:
    dmd.drawString( 7,1, "139", 3, GRAPHICS_NORMAL );  
    break;
  case 140:
    dmd.drawString( 6,1, "140", 3, GRAPHICS_NORMAL );  
    break;
  case 141:
    dmd.drawString( 7,1, "141", 3, GRAPHICS_NORMAL );  
    break;
  case 142:
    dmd.drawString( 6,1, "142", 3, GRAPHICS_NORMAL );  
    break;
  case 143:
    dmd.drawString( 6,1, "143", 3, GRAPHICS_NORMAL );  
    break;
  case 144:
    dmd.drawString( 5,1, "144", 3, GRAPHICS_NORMAL );  
    break;
  case 145:
    dmd.drawString( 6,1, "145", 3, GRAPHICS_NORMAL );  
    break;
  case 146:
    dmd.drawString( 6,1, "146", 3, GRAPHICS_NORMAL );  
    break;
  case 147:
    dmd.drawString( 6,1, "147", 3, GRAPHICS_NORMAL );  
    break;
  case 148:
    dmd.drawString( 6,1, "148", 3, GRAPHICS_NORMAL );  
    break;
  case 149:
    dmd.drawString( 6,1, "149", 3, GRAPHICS_NORMAL );  
    break;
  case 150:
    dmd.drawString( 7,1, "150", 3, GRAPHICS_NORMAL );  
    break;
  case 151:
    dmd.drawString( 8,1, "151", 3, GRAPHICS_NORMAL );  
    break;
  case 152:
    dmd.drawString( 7,1, "152", 3, GRAPHICS_NORMAL );  
    break;
  case 153:
    dmd.drawString( 7,1, "153", 3, GRAPHICS_NORMAL );  
    break;
  case 154:
    dmd.drawString( 6,1, "154", 3, GRAPHICS_NORMAL );  
    break;
  case 155:
    dmd.drawString( 7,1, "155", 3, GRAPHICS_NORMAL );  
    break;
  case 156:
    dmd.drawString( 7,1, "156", 3, GRAPHICS_NORMAL );  
    break;
  case 157:
    dmd.drawString( 7,1, "157", 3, GRAPHICS_NORMAL );  
    break;
  case 158:
    dmd.drawString( 7,1, "158", 3, GRAPHICS_NORMAL );  
    break;
  case 159:
    dmd.drawString( 7,1, "159", 3, GRAPHICS_NORMAL );  
    break;
  case 160:
    dmd.drawString( 7,1, "160", 3, GRAPHICS_NORMAL );  
    break;
  case 161:
    dmd.drawString( 8,1, "161", 3, GRAPHICS_NORMAL );  
    break;
  case 162:
    dmd.drawString( 7,1, "162", 3, GRAPHICS_NORMAL );  
    break;
  case 163:
    dmd.drawString( 7,1, "163", 3, GRAPHICS_NORMAL );  
    break;
  case 164:
    dmd.drawString( 6,1, "164", 3, GRAPHICS_NORMAL );  
    break;
  case 165:
    dmd.drawString( 7,1, "165", 3, GRAPHICS_NORMAL );  
    break;
  case 166:
    dmd.drawString( 7,1, "166", 3, GRAPHICS_NORMAL );  
    break;
  case 167:
    dmd.drawString( 7,1, "167", 3, GRAPHICS_NORMAL );  
    break;
  case 168:
    dmd.drawString( 7,1, "168", 3, GRAPHICS_NORMAL );  
    break;
  case 169:
    dmd.drawString( 7,1, "169", 3, GRAPHICS_NORMAL );  
    break;
  case 170:
    dmd.drawString( 7,1, "170", 3, GRAPHICS_NORMAL );  
    break;
  case 171:
    dmd.drawString( 8,1, "171", 3, GRAPHICS_NORMAL );  
    break;
  case 172:
    dmd.drawString( 7,1, "172", 3, GRAPHICS_NORMAL );  
    break;
  case 173:
    dmd.drawString( 7,1, "173", 3, GRAPHICS_NORMAL );  
    break;
  case 174:
    dmd.drawString( 6,1, "174", 3, GRAPHICS_NORMAL );  
    break;
  case 175:
    dmd.drawString( 7,1, "175", 3, GRAPHICS_NORMAL );  
    break;
  case 176:
    dmd.drawString( 7,1, "176", 3, GRAPHICS_NORMAL );  
    break;
  case 177:
    dmd.drawString( 7,1, "177", 3, GRAPHICS_NORMAL );  
    break;
  case 178:
    dmd.drawString( 7,1, "178", 3, GRAPHICS_NORMAL );  
    break;
  case 179:
    dmd.drawString( 7,1, "179", 3, GRAPHICS_NORMAL );  
    break;
  case 180:
    dmd.drawString( 7,1, "180", 3, GRAPHICS_NORMAL );  
    break;
  case 181:
    dmd.drawString( 8,1, "181", 3, GRAPHICS_NORMAL );  
    break;
  case 182:
    dmd.drawString( 7,1, "182", 3, GRAPHICS_NORMAL );  
    break;
  case 183:
    dmd.drawString( 7,1, "183", 3, GRAPHICS_NORMAL );  
    break;
  case 184:
    dmd.drawString( 6,1, "184", 3, GRAPHICS_NORMAL );  
    break;
  case 185:
    dmd.drawString( 7,1, "185", 3, GRAPHICS_NORMAL );  
    break;
  case 186:
    dmd.drawString( 7,1, "186", 3, GRAPHICS_NORMAL );  
    break;
  case 187:
    dmd.drawString( 7,1, "187", 3, GRAPHICS_NORMAL );  
    break;
  case 188:
    dmd.drawString( 7,1, "188", 3, GRAPHICS_NORMAL );  
    break;
  case 189:
    dmd.drawString( 7,1, "189", 3, GRAPHICS_NORMAL );  
    break;
  case 190:
    dmd.drawString( 7,1, "190", 3, GRAPHICS_NORMAL );  
    break;
  case 191:
    dmd.drawString( 8,1, "191", 3, GRAPHICS_NORMAL );  
    break;
  case 192:
    dmd.drawString( 7,1, "192", 3, GRAPHICS_NORMAL );  
    break;
  case 193:
    dmd.drawString( 7,1, "193", 3, GRAPHICS_NORMAL );  
    break;
  case 194:
    dmd.drawString( 6,1, "194", 3, GRAPHICS_NORMAL );  
    break;
  case 195:
    dmd.drawString( 7,1, "195", 3, GRAPHICS_NORMAL );  
    break;
  case 196:
    dmd.drawString( 7,1, "196", 3, GRAPHICS_NORMAL );  
    break;
  case 197:
    dmd.drawString( 7,1, "197", 3, GRAPHICS_NORMAL );  
    break;
  case 198:
    dmd.drawString( 7,1, "198", 3, GRAPHICS_NORMAL );  
    break;
  case 199:
    dmd.drawString( 7,1, "199", 3, GRAPHICS_NORMAL );  
    break;
  case 200:
    dmd.drawString( 5,1, "200", 3, GRAPHICS_NORMAL );  
    break;
  case 201:
    dmd.drawString( 6,1, "201", 3, GRAPHICS_NORMAL );  
    break;
  case 202:
    dmd.drawString( 5,1, "202", 3, GRAPHICS_NORMAL );  
    break;
  case 203:
    dmd.drawString( 5,1, "203", 3, GRAPHICS_NORMAL );  
    break;
  case 204:
    dmd.drawString( 4,1, "204", 3, GRAPHICS_NORMAL );  
    break;
  case 205:
    dmd.drawString( 5,1, "205", 3, GRAPHICS_NORMAL );  
    break;
  case 206:
    dmd.drawString( 5,1, "206", 3, GRAPHICS_NORMAL );  
    break;
  case 207:
    dmd.drawString( 5,1, "207", 3, GRAPHICS_NORMAL );  
    break;
  case 208:
    dmd.drawString( 5,1, "208", 3, GRAPHICS_NORMAL );  
    break;
  case 209:
    dmd.drawString( 5,1, "209", 3, GRAPHICS_NORMAL );  
    break;
  case 210:
    dmd.drawString( 6,1, "210", 3, GRAPHICS_NORMAL );  
    break;
  case 211:
    dmd.drawString( 7,1, "211", 3, GRAPHICS_NORMAL );  
    break;
  case 212:
    dmd.drawString( 7,1, "212", 3, GRAPHICS_NORMAL );  
    break;
  case 213:
    dmd.drawString( 6,1, "213", 3, GRAPHICS_NORMAL );  
    break;
  case 214:
    dmd.drawString( 6,1, "214", 3, GRAPHICS_NORMAL );  
    break;
  case 215:
    dmd.drawString( 7,1, "215", 3, GRAPHICS_NORMAL );  
    break;
  case 216:
    dmd.drawString( 7,1, "216", 3, GRAPHICS_NORMAL );  
    break;
  case 217:
    dmd.drawString( 7,1, "217", 3, GRAPHICS_NORMAL );  
    break;
  case 218:
    dmd.drawString( 7,1, "218", 3, GRAPHICS_NORMAL );  
    break;
  case 219:
    dmd.drawString( 7,1, "219", 3, GRAPHICS_NORMAL );  
    break;
  case 220:
    dmd.drawString( 5,1, "220", 3, GRAPHICS_NORMAL );  
    break;
  case 221:
    dmd.drawString( 6,1, "221", 3, GRAPHICS_NORMAL );  
    break;
  case 222:
    dmd.drawString( 5,1, "222", 3, GRAPHICS_NORMAL );
    break;
  case 223:
    dmd.drawString( 5,1, "223", 3, GRAPHICS_NORMAL );
    break;
  case 224:
    dmd.drawString( 4,1, "224", 3, GRAPHICS_NORMAL );  
    break;
  case 225:
    dmd.drawString( 5,1, "225", 3, GRAPHICS_NORMAL );  
    break;
  case 226:
    dmd.drawString( 5,1, "226", 3, GRAPHICS_NORMAL );  
    break;
  case 227:
    dmd.drawString( 5,1, "227", 3, GRAPHICS_NORMAL );  
    break;
  case 228:
    dmd.drawString( 5,1, "228", 3, GRAPHICS_NORMAL );  
    break;
  case 229:
    dmd.drawString( 5,1, "229", 3, GRAPHICS_NORMAL );  
    break;
  case 230:
    dmd.drawString( 5,1, "230", 3, GRAPHICS_NORMAL );  
    break;
  case 231:
    dmd.drawString( 6,1, "231", 3, GRAPHICS_NORMAL );  
    break;
  case 232:
    dmd.drawString( 5,1, "232", 3, GRAPHICS_NORMAL );  
    break;
  case 233:
    dmd.drawString( 5,1, "233", 3, GRAPHICS_NORMAL );  
    break;
  case 234:
    dmd.drawString( 4,1, "234", 3, GRAPHICS_NORMAL );
    break;
  case 235:
    dmd.drawString( 5,1, "235", 3, GRAPHICS_NORMAL );
    break;
  case 236:
    dmd.drawString( 5,1, "236", 3, GRAPHICS_NORMAL );
    break;
  case 237:
    dmd.drawString( 5,1, "237", 3, GRAPHICS_NORMAL );
    break;
  case 238:
    dmd.drawString( 5,1, "238", 3, GRAPHICS_NORMAL );
    break;
  case 239:
    dmd.drawString( 5,1, "239", 3, GRAPHICS_NORMAL );
    break;
  case 240:
    dmd.drawString( 4,1, "240", 3, GRAPHICS_NORMAL );
    break;
  case 241:
    dmd.drawString( 5,1, "241", 3, GRAPHICS_NORMAL );
    break;
  case 242:
    dmd.drawString( 4,1, "242", 3, GRAPHICS_NORMAL );
    break;
  case 243:
    dmd.drawString( 4,1, "243", 3, GRAPHICS_NORMAL );
    break;
  case 244:
    dmd.drawString( 3,1, "244", 3, GRAPHICS_NORMAL );
    break;
  case 245:
    dmd.drawString( 4,1, "245", 3, GRAPHICS_NORMAL );
    break;
  case 246:
    dmd.drawString( 4,1, "246", 3, GRAPHICS_NORMAL );
    break;
  case 247:
    dmd.drawString( 4,1, "247", 3, GRAPHICS_NORMAL );
    break;
  case 248:
    dmd.drawString( 4,1, "248", 3, GRAPHICS_NORMAL );
    break;
  case 249:
    dmd.drawString( 4,1, "249", 3, GRAPHICS_NORMAL );
    break;
  case 250:
    dmd.drawString( 4,1, "250", 3, GRAPHICS_NORMAL );
    break;
  case 251:
    dmd.drawString( 5,1, "251", 3, GRAPHICS_NORMAL );
    break;
  case 252:
    dmd.drawString( 4,1, "252", 3, GRAPHICS_NORMAL );
    break;
  case 253:
    dmd.drawString( 4,1, "253", 3, GRAPHICS_NORMAL );
    break;
  case 254:
    dmd.drawString( 4,1, "254", 3, GRAPHICS_NORMAL );
    break;
  case 255:
    dmd.drawString( 4,1, "255", 3, GRAPHICS_NORMAL );
    break;
  case 256:
    dmd.drawString( 4,1, "256", 3, GRAPHICS_NORMAL );
    break;
  case 257:
    dmd.drawString( 4,1, "257", 3, GRAPHICS_NORMAL );
    break;
  case 258:
    dmd.drawString( 4,1, "258", 3, GRAPHICS_NORMAL );
    break;
  case 259:
    dmd.drawString( 4,1, "259", 3, GRAPHICS_NORMAL );
    break;
  case 260:
    dmd.drawString( 4,1, "260", 3, GRAPHICS_NORMAL );
    break;
  case 261:
    dmd.drawString( 5,1, "261", 3, GRAPHICS_NORMAL );
    break;
  case 262:
    dmd.drawString( 4,1, "262", 3, GRAPHICS_NORMAL );
    break;
  case 263:
    dmd.drawString( 5,1, "263", 3, GRAPHICS_NORMAL );
    break;
  case 264:
    dmd.drawString( 4,1, "264", 3, GRAPHICS_NORMAL );
    break;
  case 265:
    dmd.drawString( 5,1, "265", 3, GRAPHICS_NORMAL );
    break;
  case 266:
    dmd.drawString( 5,1, "266", 3, GRAPHICS_NORMAL );
    break;
  case 267:
    dmd.drawString( 5,1, "267", 3, GRAPHICS_NORMAL );
    break;
  case 268:
    dmd.drawString( 5,1, "268", 3, GRAPHICS_NORMAL );
    break;
  case 269:
    dmd.drawString( 5,1, "269", 3, GRAPHICS_NORMAL );
    break;
  case 270:
    dmd.drawString( 5,1, "270", 3, GRAPHICS_NORMAL );
    break;
  case 271:
    dmd.drawString( 6,1, "271", 3, GRAPHICS_NORMAL );
    break;
  case 272:
    dmd.drawString( 5,1, "272", 3, GRAPHICS_NORMAL );
    break;
  case 273:
    dmd.drawString( 5,1, "273", 3, GRAPHICS_NORMAL );
    break;
  case 274:
    dmd.drawString( 4,1, "274", 3, GRAPHICS_NORMAL );
    break;
  case 275:
    dmd.drawString( 5,1, "275", 3, GRAPHICS_NORMAL );
    break;
  case 276:
    dmd.drawString( 5,1, "276", 3, GRAPHICS_NORMAL );
    break;
  case 277:
    dmd.drawString( 5,1, "277", 3, GRAPHICS_NORMAL );
    break;
  case 278:
    dmd.drawString( 5,1, "278", 3, GRAPHICS_NORMAL );
    break;
  case 279:
    dmd.drawString( 5,1, "279", 3, GRAPHICS_NORMAL );
    break;
  case 280:
    dmd.drawString( 5,1, "280", 3, GRAPHICS_NORMAL );
    break;
  case 281:
    dmd.drawString( 6,1, "281", 3, GRAPHICS_NORMAL );
    break;
  case 282:
    dmd.drawString( 5,1, "282", 3, GRAPHICS_NORMAL );
    break;
  case 283:
    dmd.drawString( 5,1, "283", 3, GRAPHICS_NORMAL );
    break;
  case 284:
    dmd.drawString( 4,1, "284", 3, GRAPHICS_NORMAL );
    break;
  case 285:
    dmd.drawString( 5,1, "285", 3, GRAPHICS_NORMAL );
    break;
  case 286:
    dmd.drawString( 5,1, "286", 3, GRAPHICS_NORMAL );
    break;
  case 287:
    dmd.drawString( 5,1, "287", 3, GRAPHICS_NORMAL );
    break;
  case 288:
    dmd.drawString( 5,1, "288", 3, GRAPHICS_NORMAL );
    break;
  case 289:
    dmd.drawString( 5,1, "289", 3, GRAPHICS_NORMAL );
    break;
  case 290:
    dmd.drawString( 5,1, "290", 3, GRAPHICS_NORMAL );
    break;
  case 291:
    dmd.drawString( 6,1, "291", 3, GRAPHICS_NORMAL );
    break;
  case 292:
    dmd.drawString( 5,1, "292", 3, GRAPHICS_NORMAL );
    break;
  case 293:
    dmd.drawString( 5,1, "293", 3, GRAPHICS_NORMAL );
    break;
  case 294:
    dmd.drawString( 4,1, "294", 3, GRAPHICS_NORMAL );
    break;
  case 295:
    dmd.drawString( 5,1, "295", 3, GRAPHICS_NORMAL );
    break;
  case 296:
    dmd.drawString( 5,1, "296", 3, GRAPHICS_NORMAL );
    break;
  case 297:
    dmd.drawString( 5,1, "297", 3, GRAPHICS_NORMAL );
    break;
  case 298:
    dmd.drawString( 5,1, "298", 3, GRAPHICS_NORMAL );
    break;
  case 299:
    dmd.drawString( 5,1, "299", 3, GRAPHICS_NORMAL );
    break;
  case 300:
    dmd.drawString( 5,1, "300", 3, GRAPHICS_NORMAL );
    break;
  case 301:
    dmd.drawString( 6,1, "301", 3, GRAPHICS_NORMAL );
    break;
  case 302:
    dmd.drawString( 5,1, "302", 3, GRAPHICS_NORMAL );
    break;
  case 303:
    dmd.drawString( 5,1, "303", 3, GRAPHICS_NORMAL );
    break;
  case 304:
    dmd.drawString( 4,1, "304", 3, GRAPHICS_NORMAL );
    break;
  case 305:
    dmd.drawString( 5,1, "305", 3, GRAPHICS_NORMAL );
    break;
  case 306:
    dmd.drawString( 5,1, "306", 3, GRAPHICS_NORMAL );
    break;
  case 307:
    dmd.drawString( 5,1, "307", 3, GRAPHICS_NORMAL );
    break;
  case 308:
    dmd.drawString( 5,1, "308", 3, GRAPHICS_NORMAL );
    break;
  case 309:
    dmd.drawString( 5,1, "309", 3, GRAPHICS_NORMAL );
    break;
  case 310:
    dmd.drawString( 6,1, "310", 3, GRAPHICS_NORMAL );
    break;
  case 311:
    dmd.drawString( 7,1, "311", 3, GRAPHICS_NORMAL );
    break;
  case 312:
    dmd.drawString( 6,1, "312", 3, GRAPHICS_NORMAL );
    break;
  case 313:
    dmd.drawString( 6,1, "313", 3, GRAPHICS_NORMAL );
    break;
  case 314:
    dmd.drawString( 6,1, "314", 3, GRAPHICS_NORMAL );
    break;
  case 315:
    dmd.drawString( 6,1, "315", 3, GRAPHICS_NORMAL );
    break;
  case 316:
    dmd.drawString( 6,1, "316", 3, GRAPHICS_NORMAL );
    break;
  case 317:
    dmd.drawString( 6,1, "317", 3, GRAPHICS_NORMAL );
    break;
  case 318:
    dmd.drawString( 6,1, "318", 3, GRAPHICS_NORMAL );
    break;  
  case 319:
    dmd.drawString( 6,1, "319", 3, GRAPHICS_NORMAL );
    break;
  case 320:
    dmd.drawString( 5,1, "320", 3, GRAPHICS_NORMAL );
    break;
  case 321:
    dmd.drawString( 6,1, "321", 3, GRAPHICS_NORMAL );
    break;
  case 322:
    dmd.drawString( 5,1, "322", 3, GRAPHICS_NORMAL );
    break;
  case 323:
    dmd.drawString( 5,1, "323", 3, GRAPHICS_NORMAL );
    break;
  case 324:
    dmd.drawString( 4,1, "324", 3, GRAPHICS_NORMAL );
    break;
  case 325:
    dmd.drawString( 5,1, "325", 3, GRAPHICS_NORMAL );
    break;
  case 326:
    dmd.drawString( 5,1, "326", 3, GRAPHICS_NORMAL );
    break;
  case 327:
    dmd.drawString( 5,1, "327", 3, GRAPHICS_NORMAL );
    break;
  case 328:
    dmd.drawString( 5,1, "328", 3, GRAPHICS_NORMAL );
    break;
  case 329:
    dmd.drawString( 5,1, "329", 3, GRAPHICS_NORMAL );
    break;
  case 330:
    dmd.drawString( 5,1, "330", 3, GRAPHICS_NORMAL );
    break;
  case 331:
    dmd.drawString( 6,1, "331", 3, GRAPHICS_NORMAL );
    break;
  case 332:
    dmd.drawString( 5,1, "332", 3, GRAPHICS_NORMAL );
    break;
  case 333:
    dmd.drawString( 5,1, "333", 3, GRAPHICS_NORMAL );
    break;
  case 334:
    dmd.drawString( 4,1, "334", 3, GRAPHICS_NORMAL );
    break;
  case 335:
    dmd.drawString( 5,1, "335", 3, GRAPHICS_NORMAL );
    break;
  case 336: 
    dmd.drawString( 5,1, "336", 3, GRAPHICS_NORMAL );  
    break;
  case 337:
    dmd.drawString( 5,1, "337", 3, GRAPHICS_NORMAL );
    break;
  case 338:
    dmd.drawString( 5,1, "338", 3, GRAPHICS_NORMAL );
    break;
  case 339:
    dmd.drawString( 5,1, "339", 3, GRAPHICS_NORMAL );  
    break;
  case 340:
    dmd.drawString( 4,1, "340", 3, GRAPHICS_NORMAL );  
    break;
  case 341:
    dmd.drawString( 6,1, "341", 3, GRAPHICS_NORMAL );  
    break;
  case 342:
    dmd.drawString( 4,1, "342", 3, GRAPHICS_NORMAL );  
    break;
  case 343:
    dmd.drawString( 4,1, "343", 3, GRAPHICS_NORMAL );  
    break;
  case 344:
    dmd.drawString( 3,1, "344", 3, GRAPHICS_NORMAL );  
    break;
  case 345:
    dmd.drawString( 4,1, "345", 3, GRAPHICS_NORMAL );  
    break;
  case 346:
    dmd.drawString( 4,1, "346", 3, GRAPHICS_NORMAL );  
    break;
  case 347:
    dmd.drawString( 4,1, "347", 3, GRAPHICS_NORMAL );  
    break;
  case 348:
    dmd.drawString( 4,1, "348", 3, GRAPHICS_NORMAL );  
    break;
  case 349:
    dmd.drawString( 4,1, "349", 3, GRAPHICS_NORMAL );  
    break;
  case 350:
    dmd.drawString( 5,1, "350", 3, GRAPHICS_NORMAL );  
    break;
  case 351:
    dmd.drawString( 7,1, "351", 3, GRAPHICS_NORMAL );  
    break;
  case 352:
    dmd.drawString( 5,1, "352", 3, GRAPHICS_NORMAL );  
    break;
  case 353:
    dmd.drawString( 5,1, "353", 3, GRAPHICS_NORMAL );  
    break;
  case 354:
    dmd.drawString( 4,1, "354", 3, GRAPHICS_NORMAL );  
    break;
  case 355:
    dmd.drawString( 5,1, "355", 3, GRAPHICS_NORMAL );  
    break;
  case 356:
    dmd.drawString( 5,1, "356", 3, GRAPHICS_NORMAL );  
    break;
  case 357:
    dmd.drawString( 5,1, "357", 3, GRAPHICS_NORMAL );  
    break;
  case 358:
    dmd.drawString( 5,1, "358", 3, GRAPHICS_NORMAL );  
    break;
  case 359:
    dmd.drawString( 5,1, "359", 3, GRAPHICS_NORMAL );  
    break;
  case 360:
    dmd.drawString( 5,1, "360", 3, GRAPHICS_NORMAL );  
    break;
  case 361:
    dmd.drawString( 6,1, "361", 3, GRAPHICS_NORMAL );  
    break;
  case 362:
    dmd.drawString( 5,1, "362", 3, GRAPHICS_NORMAL );  
    break;
  case 363:
    dmd.drawString( 5,1, "363", 3, GRAPHICS_NORMAL );  
    break;
  case 364:
    dmd.drawString( 4,1, "364", 3, GRAPHICS_NORMAL );  
    break;
  case 365:
    dmd.drawString( 5,1, "365", 3, GRAPHICS_NORMAL );  
    break;
  case 366:
    dmd.drawString( 5,1, "366", 3, GRAPHICS_NORMAL );  
    break;
  case 367:
    dmd.drawString( 5,1, "367", 3, GRAPHICS_NORMAL );  
    break;
  case 368:
    dmd.drawString( 5,1, "368", 3, GRAPHICS_NORMAL );  
    break;
  case 369:
    dmd.drawString( 5,1, "369", 3, GRAPHICS_NORMAL );  
    break;
  case 370:
    dmd.drawString( 5,1, "370", 3, GRAPHICS_NORMAL );  
    break;
  case 371:
    dmd.drawString( 6,1, "371", 3, GRAPHICS_NORMAL );  
    break;
  case 372:
    dmd.drawString( 5,1, "372", 3, GRAPHICS_NORMAL );  
    break;
  case 373:
    dmd.drawString( 5,1, "373", 3, GRAPHICS_NORMAL );  
    break;
  case 374:
    dmd.drawString( 4,1, "374", 3, GRAPHICS_NORMAL );  
    break;
  case 375:
    dmd.drawString( 5,1, "375", 3, GRAPHICS_NORMAL ); 
    break;
  case 376:
    dmd.drawString( 5,1, "376", 3, GRAPHICS_NORMAL );  
    break;
  case 377:
    dmd.drawString( 5,1, "377", 3, GRAPHICS_NORMAL );  
    break;
  case 378:
    dmd.drawString( 5,1, "378", 3, GRAPHICS_NORMAL );  
    break;
  case 379:
    dmd.drawString( 5,1, "379", 3, GRAPHICS_NORMAL );  
    break;
  case 380:
    dmd.drawString( 5,1, "380", 3, GRAPHICS_NORMAL );  
    break;
  case 381:
    dmd.drawString( 6,1, "381", 3, GRAPHICS_NORMAL );  
    break;
  case 382:
    dmd.drawString( 5,1, "382", 3, GRAPHICS_NORMAL );  
    break;
  case 383:
    dmd.drawString( 5,1, "383", 3, GRAPHICS_NORMAL );  
    break;
  case 384:
    dmd.drawString( 4,1, "384", 3, GRAPHICS_NORMAL );  
    break;
  case 385:
    dmd.drawString( 5,1, "385", 3, GRAPHICS_NORMAL );  
    break;
  case 386:
    dmd.drawString( 5,1, "386", 3, GRAPHICS_NORMAL );  
    break;
  case 387:
    dmd.drawString( 5,1, "387", 3, GRAPHICS_NORMAL );  
    break;
  case 388:
    dmd.drawString( 5,1, "388", 3, GRAPHICS_NORMAL );  
    break;
  case 389:
    dmd.drawString( 5,1, "389", 3, GRAPHICS_NORMAL );  
    break;
  case 390:
    dmd.drawString( 5,1, "390", 3, GRAPHICS_NORMAL );  
    break;
  case 391:
    dmd.drawString( 6,1, "391", 3, GRAPHICS_NORMAL );  
    break;
  case 392:
    dmd.drawString( 5,1, "392", 3, GRAPHICS_NORMAL );  
    break;
  case 393:
    dmd.drawString( 5,1, "393", 3, GRAPHICS_NORMAL );  
    break;
  case 394:
    dmd.drawString( 4,1, "394", 3, GRAPHICS_NORMAL );  
    break;
  case 395:
    dmd.drawString( 5,1, "395", 3, GRAPHICS_NORMAL );  
    break;
  case 396:
    dmd.drawString( 5,1, "396", 3, GRAPHICS_NORMAL );  
    break;
  case 397:
    dmd.drawString( 5,1, "397", 3, GRAPHICS_NORMAL );  
    break;
  case 398:
    dmd.drawString( 5,1, "398", 3, GRAPHICS_NORMAL );  
    break;
  case 399:
    dmd.drawString( 5,1, "399", 3, GRAPHICS_NORMAL );  
    break;
  case 400:
    dmd.drawString( 4,1, "400", 3, GRAPHICS_NORMAL );  
    break;
  case 401:
    dmd.drawString( 6,1, "401", 3, GRAPHICS_NORMAL );  
    break;
  case 402:
    dmd.drawString( 4,1, "402", 3, GRAPHICS_NORMAL );  
    break;
  case 403:
    dmd.drawString( 4,1, "403", 3, GRAPHICS_NORMAL );  
    break;
  case 404:
    dmd.drawString( 3,1, "404", 3, GRAPHICS_NORMAL );  
    break;
  case 405:
    dmd.drawString( 4,1, "405", 3, GRAPHICS_NORMAL );  
    break;
  case 406:
    dmd.drawString( 4,1, "406", 3, GRAPHICS_NORMAL );  
    break;
  case 407:
    dmd.drawString( 4,1, "407", 3, GRAPHICS_NORMAL );  
    break;
  case 408:
    dmd.drawString( 4,1, "408", 3, GRAPHICS_NORMAL );  
    break;
  case 409:
    dmd.drawString( 4,1, "409", 3, GRAPHICS_NORMAL );  
    break;
  case 410:
    dmd.drawString( 5,1, "410", 3, GRAPHICS_NORMAL );  
    break;
  case 411:
    dmd.drawString( 5,1, "411", 3, GRAPHICS_NORMAL );  
    break;
  case 412:
    dmd.drawString( 5,1, "412", 3, GRAPHICS_NORMAL ); 
    break;
  case 413:
    dmd.drawString( 5,1, "413", 3, GRAPHICS_NORMAL );    

  }
}

int count=0;

void loop()
{

  if (digitalRead(2)==HIGH)
  {
    count++;
    delay(1500);
    if (count>700) 
    {
      count=0;
      dmd.clearScreen(true);
    }
    drawNumber(count);
  }
  if (digitalRead(3)==HIGH)
  {
    count=0;
    delay(250);    
    dmd.clearScreen(true);    
    drawNumber(count);
  }
}

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: new to DMD

Post by Aussie_Wombat » Tue Apr 30, 2013 12:21 pm

Hi Colandra,

I modified John's code slightly, to allow for the button held down, to not continue counting, by setting a flag, once the pin goes low, the flag is reset allowing the count to continue.

I also removed the switch--case () commands from the drawNumber routine and replaced it with a digit stripper...

I added the pinmode() commands to set pins 2 and 3 to inputs..

Works ok on my etherten.

I also allowed the digits to centre on the display a little better..

Code: Select all

// DMDcountup.ino 18/04/2013 John Boxall. 
// Modified 30/4/2013 Dennis Wyatt
// HIGH on digital 2 increments number, 3 resets. 

#include <DMD.h> // for DMD
#include <SPI.h> // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <TimerOne.h> 
//#include "SystemFont5x7.h"
#include "Arial_black_16.h"
DMD dmd(1, 1); // creates instance of DMD to refer to in sketch
String txt;         //DW
int x;                //DW
void ScanDMD() // necessary interrupt handler for refresh scanning of DMD
{ 
  dmd.scanDisplayBySPI();
}

void setup()
{
  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 1110 );           //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()  
  dmd.clearScreen( true );   //true is normal (all pixels off), false is negative (all pixels on)
  dmd.selectFont(Arial_Black_16);    
  drawNumber(0);
  pinMode(2, INPUT);            // set pins to input  DW
  pinMode(3, INPUT);            //DW    

}

void drawNumber(int value)            // routine DW
{
  txt="";                          // reset txt to null
  int digit3 = value/100;          // value = 123 then value/100 = 1
  int digit2 = value/10 % 10;      // value = 123 then value/10 = 12 , then 12 mod 10 = 2
  int digit1 = value % 10;         // value = 123 then value mod 10 = 3
  txt = digit1 + txt;              // txt always displays digit1
  if (digit2 != 0){                // if digit2 not equal 0 then display digit2
      txt = digit2 + txt;
  }
  if (digit2 == 0 && digit3 !=0){  // if digit2 equals 0 and digit3 not equal 0 then display digit2
      txt = digit2 + txt;
  }
  
  if (digit3 != 0){                // if digit3 not equal 0 then display digit3
      txt = digit3 + txt;
  }
  txt=txt + " ";                  // add blank space at end to clear any previous leftover digit data
  
    char displayString[4];        // create char array
    int myTextLength = txt.length();      // find length of string
    txt.toCharArray(displayString, myTextLength+1);    //convert string to char array
    
    x= 16-(myTextLength*3);        // centre number on DMD display
    
   dmd.drawString( x,1, displayString, myTextLength, GRAPHICS_NORMAL );

}

int count=0;
boolean flag=true;        //DW

void loop()
{

  if (digitalRead(2)==HIGH){          // if pin high then enter into if routine else exit
    if (flag){                        // if flag is true enter if routine, if false then exit  DW
    count++;                          // increment count
    flag = false;                     // set flag to true. button still pressed down  DW
    delay(100);
    if (count>700){                   // max count at 700
      count=0;
      dmd.clearScreen(true);          //clear screen
    }
    drawNumber(count);                // display number
  }
  }
  if (digitalRead(2)==LOW)            //if pin goes low ( button released ) set flag to true to enable next count  DW
  {
    flag = true;
    delay(100);
  }  
  if (digitalRead(3)==HIGH)          // if this pin goes high then reset count to 0
  {
    count=0;
    delay(100);    
    dmd.clearScreen(true);          // clear screen
    drawNumber(count);
  }
}
Hopefully the comments I have added will be clear enough for you to follow the flow of the sketch..

Compiled to 9K on my etherten..

Regards Dennis.

PS. I tested with a microswitch, with the normally closed (NC) going to ground, and normally open (NO) going to 5V. The output goes to pin 2... John's pull downs resistors would probably work better overall..

cef
Freetronics Staff
Freetronics Staff
Posts: 106
Joined: Wed Nov 09, 2011 12:53 am

Re: new to DMD

Post by cef » Tue Apr 30, 2013 9:57 pm

As mentioned, for switch inputs, you're better with pull-up/pull-down resistors that tie it to the default you want.

In the case of pull-up's, there are options to tell the inputs to internally pull-up the line, but these can prove to be an issue if you're using long lead lengths to your input, due to their ability to pick up noise that will register as false triggering. Really, you want the pull-up/pull-down right next to the switch, especially if you've got a long lead length. This does mean you usually have to run 3 wires to your switch though (signal, +V and Gnd), but it definitely seems to reduce the pickup of noise.

Also good is twisting your wires (you can buy twisted cable for long runs), and of course, doing both is fine.

colandra
Posts: 4
Joined: Wed Apr 17, 2013 8:26 am

Re: new to DMD

Post by colandra » Wed May 01, 2013 2:30 am

Thank you all for your assistance, greatly appreciated.

Regards

Colandra

Post Reply