Go Down

Topic: SINGLE 3 DIGIT 7 SEGMENT LED (Read 21275 times) previous topic - next topic

cupstacker

#30
Nov 30, 2013, 01:31 am Last Edit: Nov 30, 2013, 02:18 am by cupstacker Reason: 1
giving up for now.. i said i was new to all this and right now it's just upsetting me and just making me want to stop for now. i don't know as much as any of you.

didn't know a 3 digit display and a chip would be so complicated to wire up and nobody can tell me where these wires go on the chip.. and i didn't even want the dots.. was even trying to make it easier, but guess not  :smiley-sad-blue:


thank you everyone for trying to help though

CrossRoads

#31
Nov 30, 2013, 04:36 am Last Edit: Nov 30, 2013, 04:38 am by CrossRoads Reason: 1
Overcoming the latest hurdle, understanding the package. Not all pins may exist (i.e. pin 6) - count the gap as pin if it is not there.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

graynomad

Quote
nobody can tell me where these wires go on the chip

What's wrong with Crossroad's schematic, all you have to do is identify the segment pins and the cathode pins on your display and modify the schematic accordingly.

So for example CR's drawing shows seg A on pin 1, you find where seg A is on your display and put the wire to that instead. etc etc.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

cupstacker

#33
Nov 30, 2013, 05:10 am Last Edit: Nov 30, 2013, 11:59 pm by cupstacker Reason: 1
i think i got it.. took me some time..


if that's right, now i need to know how to connect the chip to arduino and find some temp code just to see it working.. i didn't connect DP (3) because i will not be using it.

max7219 pins 4 & 9 are ground and 19 is power

arduino pin 12 is connected to the MAX7219 pin 1
arduino pin 11 is connected to the CLK pin 13
arduino pin 10 is connected to LOAD pin 12

thank you

billhowl

I saw you are using Arduino Mega which have a different pins for SPI
please check here http://arduino.cc/en/Reference/SPI



Here are the code to test the MAX7219
Code: [Select]
#include <SPI.h>

const byte MAX7219_REG_NOOP        = 0x0;
// codes 1 to 8 are digit positions 1 to 8
const byte MAX7219_REG_DECODEMODE  = 0x9;
const byte MAX7219_REG_INTENSITY   = 0xA;
const byte MAX7219_REG_SCANLIMIT   = 0xB;
const byte MAX7219_REG_SHUTDOWN    = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;

void sendByte (const byte reg, const byte data)
  {   
  digitalWrite (SS, LOW);
  SPI.transfer (reg);
  SPI.transfer (data);
  digitalWrite (SS, HIGH);
  }  // end of sendByte

void setup ()
  {
  SPI.begin ();
  sendByte (MAX7219_REG_SCANLIMIT, 2);      // show 3 digits
  sendByte (MAX7219_REG_DECODEMODE, 0xFF);  // use digits (not bit patterns)
  sendByte (MAX7219_REG_DISPLAYTEST, 0);    // no display test
  sendByte (MAX7219_REG_INTENSITY, 7);      // character intensity: range: 0 to 15
  sendByte (MAX7219_REG_SHUTDOWN, 1);       // not in shutdown mode (ie. start it up)
}   // end of setup

void number (const int num)
  {

char buf [4];
sprintf (buf, "%3i", min (max (num, 0), 999));

// send all 3 digits
for (byte digit = 0; digit < 3; digit++)
   {
   byte c = buf [digit];
   if (c == ' ' )
     c = 0xF;  // code for a blank
   else
     c -= '0';
   sendByte (digit + 1, c); 
   }   
  }  // end of number
 
unsigned int i;

void loop ()
{
number (i++);
delay (100);
}  // end of loop


cupstacker

i'm new and have not used SPI yet, probably don't plan to.. if you the exact pins to use please let me know.. otherwise i'll just wait for some normal code

thank you

billhowl

#36
Nov 30, 2013, 08:40 am Last Edit: Nov 30, 2013, 08:54 am by BillHo Reason: 1

i think i got it.. took me some time..

if that's right, now i need to know how to connect the chip to arduino and find some temp code just to see it working.. i didn't connect DP (3) because i will not be using it.

max7219 pins 4 & 9 are ground and 19 is power

arduino pin 12 is connected to the MAX7219 pin 1
arduino pin 11 is connected to the CLK pin 13
arduino pin 10 is connected to LOAD pin 12

i have my 3 buttons in place, just gotta connect them.. just need demo code to see it count or something so would someone would be so kind so i get to test this thing out please



The connection to MAX7219 is SPI, if you used Mega board then the connection will be
arduino pin 50 is connected to the MAX7219 pin 1
arduino pin 51 is connected to the CLK pin 13
arduino pin 53 is connected to LOAD pin 12


i'm new and have not used SPI yet, probably don't plan to.. if you the exact pins to use please let me know.. otherwise i'll just wait for some normal code



To talk to MAX7219 you have used SPI, this was the code used to control the MAX7219, what "normal code" you talking?

cupstacker

all i see is 3 8's.. hmm, i could swear i wired it right. i'll look when i wake up again.. it's 3:30am going back to bed

thank you

Paul__B


To talk to MAX7219 you have used SPI, this was the code used to control the MAX7219, what "normal code" you talking?


I rather think he means code that does not use the SPI.

It is not necessary; perfectly easy to write the code to "bit bang" it.

cupstacker

Quote
I rather think he means code that does not use the SPI.

yep

graynomad

read up on shiftOut(), that's a bit-banged version of SPI that can use any pins.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

cupstacker

#41
Nov 30, 2013, 03:53 pm Last Edit: Dec 01, 2013, 12:06 am by cupstacker Reason: 1
doesn't really help, first off it's using 74HC595's..

all i need is some simple code to see the 3 digits actually working.. can we stay away from SPI, i'm already confused with all this,  i have wiring back to 10,11, 12 (max 12,13, 1)

ok, nevermind a sample code.. i have 11 buttons i would like to connect to it

SEQUENCE
button 11 will "set/initiate" the display to - - - .. all other buttons are useless until this happens
buttons 1 through 10 will set the display to show in the display.. each button will have 2 values per say.. example:

button 1 is to be considered A & 1
button 10 is to be considered J & 10

you can see the rest in between..  so say i wanted the display to show b06, i would press  button 2 and then press button 6 and then press button 1 - (a certain set of leds will be lit, but we are not at this step yet) and then blanks out the display -  i would like to store a value that this button has been pressed at this point

END OF SEQUENCE

thank you

cupstacker

come to think of it - will the 11 buttons need to be connected to another chip?

thank you

CrossRoads

You need to separate your thinking into two parts - the data creation, and the data display.
Plagiarizing BillHo's code some:
Code: [Select]

#include <SPI.h>

// set up names for the 14 MAX7219 registers:
const byte MAX7219_REG_NOOP        = 0x00;
// codes 1 to 8 are digit positions 1 to 8, see below
const byte MAX7219_REG_DECODEMODE  = 0x09;
const byte MAX7219_REG_INTENSITY   = 0x0A;
const byte MAX7219_REG_SCANLIMIT   = 0x0B;
const byte MAX7219_REG_SHUTDOWN    = 0x0C;
// registers 0x0D and 0x0E are not used
const byte MAX7219_REG_DISPLAYTEST = 0x0F;
// you have 3 digits, so
const byte MAX7219_DIG0        = 0x01;
const byte MAX7219_DIG0        = 0x02;
const byte MAX7219_DIG0        = 0x03;

// 0x00,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F are same as 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15

// and 3 variables to hold data - you will change these later to have different things displayed
byte digit0 = 3;
byte digit1 = 6;
byte digit2 = 9;

byte latchPin = 10; // or whatever pin you used
// 13 SCK will connect to MAX7219 clock
// 11 MOSI will connect to MAX7219 serial data in

// now put some data in the MAX7219 registers, and setup the latchPin - backing off from the function calls

void setup ()
  {
Serial.begin(9600); // setup serial communications for debugging
pinMode (latchPin, OUTPUT);
digitalWrite (latchPin, HIGH);

// turn on SPI library - sets  up the internal hardware for SCK, MISO, MOSI
SPI.begin (); // transfers to the MAX7219 will use default speed of 4 MHz

// now setup the 5 registers that control things
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_REG_SCANLIMIT);      // send address
SPI.transfer (2); // send data to show 3 digits
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the other registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_REG_DECODEMODE);      // send address
SPI.transfer (0xFF); // use internal mapping to create the digits
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the other registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_REG_DISPLAYTEST);      // send address
SPI.transfer (0); // no display test (display test on turns on all segments)
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the other registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_REG_INTENSITY);      // send address
SPI.transfer (7); // mid level intensity, 0 to 15
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the other registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_REG_SHUTDOWN);      // send address
SPI.transfer (1); // 1 = not shutdown mode
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

// MAX7219 control registers all set, send some data!
Serial.println ("MAX7219 Setup done");

//continue for the data registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_DIG0);      // send address
SPI.transfer (digit0); // data
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the data registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_DIG1);      // send address
SPI.transfer (digit1); // 1 = not shutdown mode
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

//continue for the other registers
digitalWrite (latchPin, LOW);
SPI.transfer (MAX7219_DIG2);      // send address
SPI.transfer (digit2); // 1 = not shutdown mode
digitalWrite (latchPin,  HIGH); // data latched on this signal going Low to High

Serial.println ("End of Setup");
}   // end of setup
void loop(){
}

That should display 3,6,9 for you and send a couple of message to the serial monitor at 9600.

You should be able to read this and find the matching portions of the datasheet to see where the info is coming from.

Get this working, we can discuss reading buttons, changing the values in digit0,digit1, digit2, and sending the updated digits to the MAX7219 for display updates. That will happen in void loop(), which is currently empty.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

cupstacker

#44
Dec 01, 2013, 03:02 am Last Edit: Dec 01, 2013, 03:09 am by cupstacker Reason: 1
const byte MAX7219_DIG0        = 0x02;

error.. says redefinition of 'const byte MAX7219_DIG0'

changed
const byte MAX7219_DIG0        = 0x01;
const byte MAX7219_DIG0        = 0x02;
const byte MAX7219_DIG0        = 0x03;

to

const byte MAX7219_DIG0        = 0x01;
const byte MAX7219_DIG1        = 0x02;
const byte MAX7219_DIG2        = 0x03;

and it uploaded, but nothing happened - all blank

Go Up