change display from LCD to Max7219 8 digit 7segment LED

Have a program written for an LCD display for a DRO using a quadrature encoder and I have been looking at ways to change the display from LCD to LED to make it easier to read. There are units on Ebay using the MAX7219. Need to know if I am on the right track here. I have studied many programs on the web to do with Arduino and the MAX7219 , all are different in one way or another. So will it be a matter of defining the LED library, change pinMode to include the new pins required.

It appears the loop section for the LCD mainly reads the data collected so where would be a good place to look for how I can do this with the 7219.? The encoder is read using 2 intrerrupts but I am new to this and still need to see where the data is stored. LCD readout appears to be much easier to do really.

Unless you post the code (using "code" tags from the [ # ] icon) and any relevant photographs (perfectly focused and resolution 1024 x 768 or slightly less), we will never know, will we?

Had thought about doing just that but I am concerned there may be some form of copyright on it.

As this heading was "guidance" I thought I would ask for general guidance if that makes sense.

.

If you can't be more forthcoming, you can't expect any guidance either. One thing I can tell you is that using 7segs with the 7221 is very different to using LCDs, and you are right about LCDs being easier - to the point where you might be better off using an LCD display more appropriate to your needs instead, but there is an article on the 7221 in the Arduino playground.

LCDs easier? With MAX7219/7221, you set up 5 registers in setup(), then you send digit info to 1 of 8 data registers when you want the output updated. Pretty simple!

Every access is this format, using SPI.transfer:

digitalWrite (ssPIN, LOW); SPI.transfer(registerAddress); // 1 to 8 are the data registers, 9,A,B,C,F are the others to set up SP.transfer(dataToLoad); digitalWrite(ssPIN, HIGH); // outputs update on this rising edge.

0.1uF and 10uF cap from Vcc to Gnd, 10K resistor from pin 18 to 19. Works great with default settings that SPI.begin( ); uses: 4 MHz, SPI mode 0.

Thankyou Crossroads, Your guidance is appreciated greatly. Your information will enable me to continue. Thanks again.

CrossRoads: LCDs easier? With MAX7219/7221, you set up 5 registers in setup(), then you send digit info to 1 of 8 data registers when you want the output updated. Pretty simple!

Every access is this format, using SPI.transfer:

digitalWrite (ssPIN, LOW); SPI.transfer(registerAddress); // 1 to 8 are the data registers, 9,A,B,C,F are the others to set up SP.transfer(dataToLoad); digitalWrite(ssPIN, HIGH); // outputs update on this rising edge.

0.1uF and 10uF cap from Vcc to Gnd, 10K resistor from pin 18 to 19. Works great with default settings that SPI.begin( ); uses: 4 MHz, SPI mode 0.

and in LCD, it is

go there;
print that;
go there;
print that;

What's the library code behind that? I've never used one.

While working on the above I saw that a library SoftwareSerial was needed so I went to Sketch, import library and clicked on SoftwareSerial. It added it to the editor window as # include <SoftwareSerial.h> but, as with other libraries added, this one does not turn red. Is this a problem or not…??

Just wondering if I am on the right track here.
Compiles ok but possibly some programming errors … all a new learning curve for me.
Thanks…Jorgo

// DRO modified from LCD to LED display using 8 digit 7 Segment with MAX7219 Driver.
// more to do on the Inch versus Metric arrangement
// 18/6/2014 Version 0.2
#include <LedControl.h> 		// include LED library
LedControl lc=LedControl(12,11,10,1);
#include <Encoder.h>			// include ENCODER library
#include <SPI.h>			// include Serial Peripheral Interface library
#define encoder0PinA 3			// assigns name "encoderpinA" to pin 3 (interrupt pin in this case)
#define encoder0PinB 2			// assigns name "encoderpinB" to pin 2 (interrupt pin in this case)
#define zeroPin 5			// assigns name "zeroPin" to pin 5. This pin zeros the display.
#define inchPin 4			// assigns name "inchPin" to pin 4. This pin selects either inches or millimetres to be displayed.
// calculations for this are done elsewhere
#define CS 10                           // SS,CS or latch pin, set low to transfer data
#define CLK 13                          // Not sure about right pin here or not
#define DIN 11                          // set MOSI pin Master Out Slave In, this carries the data transfered
volatile long encoder0Pos=0;
float tmp=0;
long Aold=0;
long Bnew=0;
float Mpitch=1;
float Ipitch;
float Slots=200;


void setup(){
  Slots *=4;                            // convert slots to edges 
  Ipitch = Mpitch * 0.0393700787;
  pinMode(CS,OUTPUT);		        // make latchPin an output(to MAX7219)
  pinMode(CLK,OUTPUT);			// make clockpin an output( "    "   )
  pinMode(DIN,OUTPUT);		        // make the datapin an output( "  "  )
  pinMode(encoder0PinA,INPUT);		// make encoderPinA an input
  pinMode(encoder0PinB,INPUT);		// make encoderpinB an input
  attachInterrupt(1, doEncoderA, CHANGE);	// encoder on interrupt 1 (pin3)look for change in signal
  attachInterrupt(0, doEncoderB,CHANGE); 	// encoder on interrupt 0 (pin2)look for change in signal
  lc.shutdown(0,false);
  lc.setIntensity(0,8);


  SPI.begin();                             // initialise Serial Peripheral Interface
  SPI.setBitOrder(MSBFIRST);              // MAX7219 requires most signifigant bit first
  digitalWrite(CS,HIGH);                  // disables data input to the display
}



void loop(){                     // start
  if (tmp != encoder0Pos || (digitalRead(zeroPin) == 0 )){
    if (digitalRead(zeroPin) == 0){
      tmp = 0;
      encoder0Pos = 0;
    }
    if(digitalRead(inchPin) == 0){
      tmp = encoder0Pos / Slots * Ipitch;
      digitalWrite(CS,LOW);		// enable, ready for data flow
      SPI.transfer(tmp);              // transfer byte of data from the encoder
      digitalWrite(CS,HIGH);		// disable again 
    }
    else {
      tmp = encoder0Pos / Slots * Mpitch;
      digitalWrite(CS,LOW);		// enable, ready for data flow
      SPI.transfer(tmp);              // transfer byte of data from the encoder
      digitalWrite(CS,HIGH);		// disable again 
    }
  }

}

//Interrupt A

void doEncoderA(){
  Bnew^Aold ? encoder0Pos++:encoder0Pos--;//if Bnew=Aold, increment, otherwise decrement
  Aold=digitalRead(encoder0PinA);		

}
//Interrupt B
void doEncoderB(){
  Bnew=digitalRead(encoder0PinB);
  Bnew^Aold ? encoder0Pos++:encoder0Pos--;

}

AsCrossroads said: SPI.transfer(registerAddress); // 1 to 8 are the data registers, 9,A,B,C,F are the others to set up SP.transfer(dataToLoad);

Some great info HERE. See "Connecting a 7-segment LED"

Spent 4 days looking for information relating to what has been quoted here but I am no further advanced. I'm beginning to think that Nick_Pyner #4 might be on the right track by saying LCD much earier.

Seems that those that are in the know forget how difficult it can be for newcommers to get their head around some of what appears to new commers as short-cut answers.

I know it probably makes complete sense to them but it can be confusing to some. In the example given in the above reply, there is code that appears to quote registers, but in some of the examples I've seen they refer to lc.shutdown etc. I see no mention of any of this in the above reference example.

I thought it would be fairly simple to send a binary number (say decimal 13..... 00001101) to the Max7219 and it would display 13. Not sure how it would handle any floating point number to operate the decimal point though but that is query for another day.

I will persist though and thanks to all the input...much appreciated.

This part of Nicks code does the formatting.

void sendByte (const byte reg, const byte data)
  {    
  digitalWrite (SS, LOW);
  SPI.transfer (reg);
  SPI.transfer (data);
  digitalWrite (SS, HIGH); 
  }  // end of sendByte
 
 
void number (const int num)
  {
 
 char buf [5];
 sprintf (buf, "%4i", min (max (num, 0), 9999));
 
 // send all 4 digits
 for (byte digit = 0; digit < 4; digit++)
   {
   byte c = buf [digit];
   if (c == ' ' )
     c = 0xF;  // code for a blank
   else
     c -= '0';
   sendByte (digit + 1, c);  
   }   
  }  // end of number

All you have to do is is a call like:
number (YourNumberYouWantPrinted);

Here I use 8 digit display:

When you need a decimal point, you add code to detect the ASCII code for , then turn on the "dp" like I do in my example.

Spent 4 days looking for information relating to what has been quoted here but I am no further advanced.

I think this thread

http://forum.arduino.cc//index.php?topic=172192.msg1279382#msg1279382

might say a bit about what's going on with 7-seg displays

I have hesitated to bring this code up as it bears little resemblance to the discussion of experts, and we might even be at cross-purposes anyway. It was derived from the playground stuff mentioned in reply#4,

http://playground.arduino.cc/Main/MAX72XXHardware#.UxPXAc76U1I

with help from some guy in Florida who was the only person in the known universe who could explain numerical output to 7 segs in a sensible, non-mindboggling manner.

I think there are better, or at least slicker, ways, but the above might be understandable, and then expandable to the required eight digits.

OK...well, I will look into everything you have supplied here and see if I can get my head around it all.

Thanks again for the input...I'll be back when I sort it..... cheers ..Jorgo