matrix code

Hi, can anyone tell me how to display only one led in this matrix? then I now hot to display one led which I want I can do anything with matrix. I need a code sample. this code is to hard for me, I dont need running text, just turn on some leds. I have 9x10 matrix, and I made my matrix by this one: http://www.instructables.com/id/Make-a-24X6-LED-matrix/?ALLSTEPS
thanks for hellp

#define A {B01110000,B10001000,B10001000,B11111000,B10001000,B10001000}
#define B {B11110000,B10001000,B10001000,B11110000,B10001000,B11111000}
#define C {B11111000,B10000000,B10000000,B10000000,B10000000,B11111000}
#define D {B11110000,B10001000,B10001000,B10001000,B10001000,B11110000}
#define E {B11111000,B10000000,B10000000,B11110000,B10000000,B11111000}
#define F {B11111000,B10000000,B10000000,B11110000,B10000000,B10000000}
#define G {B01110000,B10001000,B10000000,B10011000,B10001000,B01110000}
#define H {B10001000,B10001000,B11111000,B10001000,B10001000,B10001000}
#define I {B11111000,B00100000,B00100000,B00100000,B00100000,B11111000}
#define J {B00111000,B00010000,B00010000,B00010000,B10010000,B01100000}
#define M {B10001000,B11011000,B10101000,B10101000,B10001000,B10001000}
#define N {B10001000,B11001000,B10101000,B10101000,B10011000,B10001000}
#define L {B10000000,B10000000,B10000000,B10000000,B10000000,B11111000}
#define O {B01110000,B10001000,B10001000,B10001000,B10001000,B01110000}
#define P {B11110000,B10001000,B10001000,B11110000,B10000000,B10000000}
#define Q {B01110000,B10001000,B10101000,B10011000,B01111000,B00001000}
#define R {B11110000,B10001000,B10001000,B11110000,B10001000,B10001000}
#define S {B01110000,B10001000,B01100000,B00010000,B10001000,B01110000}
#define K {B10001000,B10010000,B11100000,B11100000,B10010000,B10001000}
#define T {B11111000,B00100000,B00100000,B00100000,B00100000,B00100000}
#define U {B10001000,B10001000,B10001000,B10001000,B10001000,B01110000}
#define V {B10001000,B10001000,B10001000,B10001000,B01010000,B00100000}
#define W {B10001000,B10001000,B10101000,B10101000,B10101000,B01010000}
#define X {B10001000,B01010000,B00100000,B00100000,B01010000,B10001000}
#define Y {B10001000,B01010000,B00100000,B00100000,B00100000,B00100000}
#define Z {B11111000,B00001000,B00110000,B01100000,B10000000,B11111000}

int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int latchPinPORTB = latchPin - 8;
int clockPinPORTB = clockPin - 8;
int dataPinPORTB = dataPin - 8;
int i = 0;
long scrolling_word[6];
int array_turn=0;
byte your_text[8][6]={H,I,SPACE,W,O,R,L,D};//PUT YOU TEXT HERE


void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  setupSPI();
}

void display_word(int loops,byte word_print[][6],int num_patterns,int delay_langth){// this function displays your symbols
  i = 0;// resets the counter fot the 4017
  for(int g=0;g<6;g++)//resets the the long int where your word goes
    scrolling_word[g] = 0;
  for(int x=0;x<num_patterns;x++){//main loop, goes over your symbols
   // you will need to find a better way to make the symbols scroll my way is limited for 24 columns

   for(int r=0;r<6;r++)//puts the buildes the first symbol
      scrolling_word[r] |= word_print[x][r]; 
    for (int z=0;z<6;z++){//the sctolling action
        for(int p=0;p<6;p++)
          scrolling_word[p] = scrolling_word[p] << 1;
// end of the scrolling funcion
      for(int t=0;t<delay_langth;t++){// delay function, it just loops over the same display
        for(int y=0;y<6;y++){// scaning the display
          if(i == 6){// counting up to 6 with the 4017
            digitalWrite(Reset,HIGH);
            digitalWrite(Reset,LOW);
            i = 0;
          }
          latchOff();
          spi_transfer(make_word(0x01000000,y));// sending the data
          spi_transfer(make_word(0x00010000,y));
          spi_transfer(make_word(0x00000100,y));
          latchOn();
          delayMicroseconds(800);//waiting a bit
          latchOff();
          spi_transfer(0);// clearing the data
          spi_transfer(0);
          spi_transfer(0);
          latchOn();
          digitalWrite(clock,HIGH);//counting up with the 4017
          digitalWrite(clock,LOW);
          i++;
        }
      }
    }
  }
  finish_scroll(delay_langth);
}

void finish_scroll(int delay_scroll){// this function is the same as the funcion above, it just finishing scrolling
  for (int n=0;n<24;n++){
        for(int h=0;h<6;h++)
          scrolling_word[h] = scrolling_word[h] << 1;
      for(int w=0;w<delay_scroll;w++){
        for(int k=0;k<6;k++){
          if(i == 6){
            digitalWrite(Reset,HIGH);
            digitalWrite(Reset,LOW);
            i = 0;
          }
          latchOff();
          spi_transfer(make_word(0x01000000,k));
          spi_transfer(make_word(0x00010000,k));
          spi_transfer(make_word(0x00000100,k));
          latchOn();
          delayMicroseconds(800);
          latchOff();
          spi_transfer(0);
          spi_transfer(0);
          spi_transfer(0);
          latchOn();
          digitalWrite(clock,HIGH);
          digitalWrite(clock,LOW);
          i++;
        }
      }
    }
}

byte make_word (long posistion,byte turn){
  byte dummy_word = 0;
  for(int q=0;q<8;q++){
    if(scrolling_word[turn] & (posistion<<q))
      dummy_word |= 0x01<<q;
  }
  return dummy_word;
}   


  void loop() {

        display_word(1,your_text,8,15);// calls for the display_pattern function and says that int loop = 15(if you do more loop the pattern whould scrole slower).
   
       }
  
  

void latchOn(){
  bitSet(PORTB,latchPinPORTB);
}

void latchOff(){
  bitClear(PORTB,latchPinPORTB);
}


void setupSPI(){
  byte clr;
  SPCR |= ( (1<<SPE) | (1<<MSTR) ); // enable SPI as master
  //SPCR |= ( (1<<SPR1) | (1<<SPR0) ); // set prescaler bits
  SPCR &= ~( (1<<SPR1) | (1<<SPR0) ); // clear prescaler bits
  clr=SPSR; // clear SPI status reg
  clr=SPDR; // clear SPI data reg
  SPSR |= (1<<SPI2X); // set prescaler bits
  //SPSR &= ~(1<<SPI2X); // clear prescaler bits

  delay(10);
}
byte spi_transfer(byte data)
{
  SPDR = data;			  // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
  return SPDR;			  // return the received byte, we don't need that
}

Post your schematic, lets start from there. Then controlling individual LEDs is just a matter sending the correct column & row data.

my project looks like this one: http://www.instructables.com/id/Make-a-24X6-LED-matrix/?ALLSTEPS but in my matrix is 10 rows and 9 colums. I use all ten 4017 decade counter outputs. this code works for me but I do not understand it, and works only for 6 rows. I just want to know how to turn on led in matrix, I dont need running text

Ok, So you've modified this somehow? What did you change?

yes, I use only two 74hc595n one use 8 outputs and another use only one output. in 4017 use 1, 2, 3, 4, 5, 6, 7, 9, 10, 11 legs as row output

Try something like this.
Should be kinda close.

/* 9 high x 10 across array */
/* turn on 1 LED */

byte latchPin = 10;
byte clockPin = 13;
byte dataPin = 11;
byte clock = 9;
byte Reset = 8;
bye x;
int rowByte;
byte upperrowByte;
byte lowerrowByte;
int columnByte;
int displayArray [] = {B00000000001, B0000000010, B0000000100, B0000001000, B0000010000, B0000100000,
B0001000000, B0010000000, B0100000000, B1000000000};

void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  SPI.begin();
}

  void loop() {

for (x = 0; x<10; x=x+1){
digitalWrite (latchpPin, LOW);
SPI.transfer (highByte (displayArray[x]) );
SPI.transfer (lowByte (displayArray[x]) );
digitalWrite (latchPin, HIGH);
delay (25);
digitalWrite (clock, High);
digitalWrite (clock, LOW);
}
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}// end void loop

Not at home, don’t know if it will compile without errors.

show this error: http://imageshack.us/f/803/problemaoe.jpg/

That image is a bit fuzzy, but your problem is that your binary constants are too long. The B00000000 style binary constants are Arduino specific, and are just a set of #defines (I believe), which are only defined as eight digits. You could try the 0b00000000 gcc version, which may allow longer numbers.

0b00000000 fix this error but now: SPI.begin(); was not declarate in this scope

And, what is a SPI that you want to begin? You are missing at least an include statement.

could you write correct code?

could you write correct code?

Sure. Send me you hardware, and your requirements. When I’m done, I’ll send it back.

Meanwhile, you might try adding

#include <SPI.h>

to your code.

I'm not convinced 9 bits will fit into a byte.

when I use #include <SPI.h> there is no more errors!
when I came home try to upload code in arduino
my project looks the same as this one: http://www.instructables.com/id/Make-a-24X6-LED-matrix/?ALLSTEPS
but in my matrix is 10 rows and 9 colums.
I use only two 74hc595n, one use 8 outputs and another use only one output. in 4017 use 1, 2, 3, 4, 5, 6, 7, 9, 10, 11 legs as row output
whats all what I change.

still not working with this code:

/* 9 high x 10 across array */
/* turn on 1 LED */
#include <SPI.h>
byte latchPin = 10;
byte clockPin = 13;
byte dataPin = 11;
byte clock = 9;
byte Reset = 8;
byte x;
int rowByte;
byte upperrowByte;
byte lowerrowByte;
int columnByte;
int displayArray [] = {0b1111111111,0b0000000000};

void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  SPI.begin();
}

  void loop() {

for (x = 0; x<10; x=x+1){
digitalWrite (latchPin, LOW);
SPI.transfer (highByte (displayArray[x]) );
SPI.transfer (lowByte (displayArray[x]) );
digitalWrite (latchPin, HIGH);
delay (25);
digitalWrite (clock, HIGH);
digitalWrite (clock, LOW);
}
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}// end void loop

all matrix just blinking

So fix the parts that were suggested to you:

add the missing library call
the display array needs to be 9 bits as thats how tall the display is, and 10 bits wide
the display array needs to be 10 elements, so each element can be called up to go with the column drive.

#include <SPI.h>

/* 9 high x 10 across array */
/* turn on 1 LED */
#include <SPI.h>
byte latchPin = 10;
byte clockPin = 13;
byte dataPin = 11;
byte clock = 9;
byte Reset = 8;
byte x;
int rowByte;
byte upperrowByte;
byte lowerrowByte;
int columnByte;
// define the LEDs to be turned on. Assuming 1 = on, flip over of 1 = off
// need 10 defined as will be calling out displayArray[0] thru displayArray[9] in the loop
int displayArray [] = {
B00000001, 
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000};

void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  SPI.begin();
}

  void loop() {

for (x = 0; x<10; x=x+1){
digitalWrite (latchPin, LOW);
SPI.transfer (highByte (displayArray[x]) );
SPI.transfer (lowByte (displayArray[x]) );
digitalWrite (latchPin, HIGH);
delay (25);
digitalWrite (clock, HIGH);
digitalWrite (clock, LOW);
}
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}// end void loop

it works! but led blinking, how to make led shine all the time?

make delay(25) shorter, like 5, 1, or maybe comment it out altogether.

you are the best man! finally it works like I want! you and others really helped my!

what about changing led? How to something like this: turn on one led nr1, delay one second then turn off led nr1 and turn on led nr2?