Alphanumerical LED Display Error

Hi I have been getting an error with my coding here. The error is

"Sts.cpp:24: error: expected primary-expression before ‘void’
Sts.cpp:24: error: expected `}’ before ‘void’
Sts.cpp:24: error: expected ‘,’ or ‘;’ before ‘void’

Here is my code. Any help? I am trying to make the LED spell out different sayings. Gonna ask out a girl in a Tron suit :wink: But I have already gotten it to work for my dance show.

/*
Adapted from Ben Duncan’s code by John Nussey 23rd November 2009
Shared under Creative Commons
Give easy control of Alphanumeric LED displays
(Kingbright type)
*/

#include “Arduino.h”
#include “Sts.h”

byte characters[36][16] = {
{1,1,0,0,0,1,0,0,1,1,1,0,0,1,0,1}, // D
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
{0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
{1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1}, // C
{1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1}, // E
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, //
{1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1}, // M
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
{0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
{1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1}, // I
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A

void Sts::setPins(){
for(int i=2; i<18;i++){
pinMode(i, OUTPUT);
}
}

void Sts::displayChar(int _charNum)
{
for(int i=0; i<16;i++){
digitalWrite((i+2), characters[_charNum]);

  • }*
    }
    [/quote]

You’re missing:

void setup{
//presumably you'd call setPins in here
}
void loop(){
// presumably you'd call displayChar in here
}

Sorry Im pretty new to this. Where would that go in the sketch?

Wait sorry. That's all in a different Tab in my sketch

Your bidimensional array is missing a closing curly brace.

Yes, was just gonna say that:

byte characters[36][16] = {
{1,1,0,0,0,1,0,0,1,1,1,0,0,1,0,1}, // D
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
{0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
{1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1}, // C
{1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1}, // E
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, //
{1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1}, // M
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
{0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
{1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1}, // I
{1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
}; <<<<<<

I tried that before. Copied yours exactly and I still have errors. Would it help if I posted the entire sketch?

Johnny_Gan: I tried that before. Copied yours exactly and I still have errors. Would it help if I posted the entire sketch?

According to the How to use this forum thread, yes.

It would also help to use CODE tags instead of the copy to forum option. Lastly, when you make changes and still get errors, posts the new code with those changes, as well as the actual error messsage.

Whoops sorry. :frowning:

/*
 Adapted from Ben Duncan's code by John Nussey 23rd November 2009
 Shared under Creative Commons
 Give easy control of Alphanumeric LED displays
 (Kingbright type)
 */

#include "Sts.h" // Include the Seventeen Segment library

Sts Sts; // Create the Sts object

void setup(){
 Sts.setPins(); 
}

 void loop() {
 for(int i=0; i<36; i++){
 Sts.displayChar(i); // Display the capital character
 delay(1000); // Wait 1 second
 }
 }
/*
 Adapted from Ben Duncan's code by John Nussey 23rd November 2009
 Shared under Creative Commons
 Give easy control of Alphanumeric LED displays
 (Kingbright type)
 */

#include "Arduino.h"
#include "Sts.h"

byte characters[36][16] = {
  {1,1,0,0,0,1,0,0,1,1,1,0,0,1,0,1}, // D
  {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
  {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
  {1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1}, // C
  {1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,1}, // E
  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // 
  {1,1,0,1,0,0,0,1,0,0,1,0,0,1,0,1}, // M
  {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
  {0,0,1,1,0,0,0,1,0,0,1,1,0,1,0,0}, // N
  {1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1}, // I
  {1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1}, // A
};

void Sts::setPins(){
 for(int i=2; i<18;i++){
 pinMode(i, OUTPUT);
 }
}

void Sts::displayChar(int _charNum)
{
 for(int i=0; i<16;i++){
 digitalWrite((i+2), characters[_charNum][i]);
 }
}
/*
 Adapted from Ben Duncan's code by John Nussey 23rd November 2009
 Shared under Creative Commons
 Give easy control of Alphanumeric LED displays
 (Kingbright type)
 */

#ifndef Sts_h
#define Sts_h

#include "Arduino.h"

class Sts
{
public:
 void setPins();
 int _charNum;
 void displayChar(int _charNum);
 byte charactersCap[36][16];
private:

};

#endif

EDIT: Error Message

Error Compiling

C:\Users\Rich\Documents\Arduino\libraries\sketch_may03c\Sts.cpp:24: error: expected primary-expression before 'void'
C:\Users\Rich\Documents\Arduino\libraries\sketch_may03c\Sts.cpp:24: error: expected `}' before 'void'
C:\Users\Rich\Documents\Arduino\libraries\sketch_may03c\Sts.cpp:24: error: expected ',' or ';' before 'void'

So what is the error now?

CrossRoads: So what is the error now?

Sorry I edited my post as you replied. See above :)

I would try putting the 2nd tab code in after the 1st tab code, and bringing all the #includes to the top, deleting any duplicates. Put the array before void setup. I've never written anything where the tabs were used as separate programs like that.