Keep getting errors and im super lost

so im trying to display ESE! on a 6x24 LED array but when I compile and verify it, I keep getting errors and don't know what the issue. i pasted the code below

Code:

#include <stdio.h> // some Arduino-specific libraries are pre-included.  They can be picked from within the Library tab in Arduino IDE.
#define SERIAL_CLOCK 12 // shifts data into shift registers when pulsed (SRCLK)
#define LATCH_CLOCK  11 // releases shift register data to LED matrix when pulsed (RCLK)
#define SERIAL_DATA  10 // data line for the shift registers 
#define DEMUX_A 7
#define DEMUX_B 8
#define DEMUX_C 9

//initalizes pin outputs
pinMode(SERIAL_CLOCK, OUTPUT);
pinMode(LATCH_CLOCK, OUTPUT);
pinMode(SERIAL_DATA, OUTPUT);

pinMode(DEMUX_A, OUTPUT);
pinMode(DEMUX_B, OUTPUT);
pinMode(DEMUX_C, OUTPUT);


//**All other preprocessor directives will be placed here


// The two scripting functions prototyped right here.  Also hidden.
void setup();
void loop();

//**All other prototypes and global variables are added here


//this section is completely hidden in the back scene of Arduino C Scripting Environment
void main()
{	
	// declared variables in Arduino are pasted here
	
	
	setup(); //calling setup function ONCE
	
	while(1) //infinite while loop / PROGRAM LOOP
	{ 
		loop();
	}
	
}


/*	
	- Function Name: start()
	- Purpose: Initialization Sequence for Arduino Embedded Target

	- Input(s):		Variable Name	Variable Type	Purpose
					No input

	- Output:		Return Type
	  				no return type required
*/

#define BUF_LEN 200
#define STR_LEN 30    //this means I only can support up to 15 characters pre-drawn


char myLEDDisplayBuffer[6][BUF_LEN];  // this is my 6x120 LED array display buffer
// the first 6x6 section of this buffer will be filled by
{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } , 
{'1', '1', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', } ,
{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
{'1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', } ,
{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } 

char string[STR_LEN] = "ESE!";  // {'E', 'S', 'E', '!', '\0'}

char charE[6][6] = { {'1', '1', '1', '1', '1', '1'} , 
					 {'1', '1', '0', '0', '0', '0'} ,
					 {'1', '1', '1', '1', '1', '1'} ,
					 {'1', '1', '1', '1', '1', '1'} ,
					 {'1', '1', '0', '0', '0', '0'} ,
					 {'1', '1', '1', '1', '1', '1'} 
					 };
					 
char charS[6][6] = { {'1', '1', '1', '1', '1', '1'} , 
					 {'1', '1', '0', '0', '0', '0'} ,
					 {'1', '1', '1', '1', '1', '1'} ,
					 {'1', '1', '1', '1', '1', '1'} ,
					 {'0', '0', '0', '0', '1', '1'} ,
					 {'1', '1', '1', '1', '1', '1'} 
					 };
					 
char puncExcl[6][3] = { {'1', '1', '1'} , 
					    {'1', '1', '1'} ,
					    {'1', '1', '1'} ,
					    {'1', '1', '1'} ,
					    {'0', '0', '0'} ,
					    {'1', '1', '1'} 
					  };
					  
int windowPointer = 0;

#define ROLLING_DELAY 500;
int startTime = 0;


void assembleString()
{
	// need an assmebly pointer
	int pointer = 0;
	
	for(int i = 0; i < STR_LEN; i++)
	{		
		if(string[i] == 'E')
		{
			// load the E pattern using nested for-loop	
			for(int j = 0; j < 6; j++) // row
			{
				for(int k = 0; k < 6; k++) //col
				{
					myLEDDisplayBuffer[j][k + pointer] = charE[j][k]; 
				}
			}
			
			// increase my pointer 6 + 1 unit 		
			pointer += 7;
			
		}
		else if(string[i] == 'S')
		{
			// load the S pattern using nested for-loop
			for(int j = 0; j < 6; j++) // row
			{
				for(int k = 0; k < 6; k++) //col
				{
					myLEDDisplayBuffer[j][k + pointer] = charS[j][k]; 
				}
			}
			
			// increase my pointer 6 + 1 unit 	
			pointer += 7;	
		}
		else if(string[i] == '!')
		{
			// Load the ! pattern using nested for-loop
			// increase my pointer 3 + 1 unit 		
		}
		
	}

}


void setup();  // function, ONLY RUN ONCE
{
   	// put your setup code here, to run once:
    
    assembleString();
}  // myOtherIndex will be destroyed....


/*	
	- Function Name: loop()
	- Purpose: The Master Program Loop (Game Loop) Arduino Embedded Target, repeats forever

	- Input(s):		Variable Name	Variable Type	Purpose
					No input

	- Output:		Return Type
	  				no return type required
*/

void loop() //function
{
	// put your main code here, to run repeatedly:
	
	
	// the way to roll the display / move the sliding window (mask) is to add the "scanner offset"
	//  i.e. the windowPointer...
	
	{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } , 
	{'1', '1', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', } ,
	{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
	{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
	{'1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', } ,
	{'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } 
	
	// question... what would happen if windowPointer > 8 (e.g. 10)
	
	// because windowPointer is constantly increased for every program iteration, at one point, windowPointer + col > BUF_LEN
	// (col + windowPointer) % BUF_LEN  (e.g. col: [0 .. 5], windowPointer: 10, BUF_LEN = 14)
	//  [10] % 14 = 10
	//  [11] % 14 = 11
	//  [12] % 14 = 12
	//  [13] % 14 = 13
	//  [14] % 14 = 0
	//  [15] % 14 = 1
	
	// modulus with BUF_LEN on the col index will ensure that myLEDDisplayBuffer becomes a CIRCULAR BUFFER
	
	
	// this part needs to be executed as fast as possible
	for(int row = 0; row < 6; row++)
	{
		// 1. Send the corresponding ABC selection signals to the DEMUX to turn on the row indexed by the variable "row" in the for loop.
		
		// 2. load all LED bits to the LED column shift register bank
		for( int col = 0; col < 6; col++)
		{
			if( myLEDDisplayBuffer[row][ (col + windowPointer) % BUF_LEN ] == '0' )
				digitalWrite(SERIAL_DATA, HIGH);		// digital write HIGH to the Serial Data!
			else
				digitalWrite(SERIAL_DATA, LOW);			// digital write LOW to the serial data.
				
			 digitalWrite(SERIAL_CLOCK, HIGH);			// clock the shift register once!
    		digitalWrite(SERIAL_CLOCK, LOW);
		}
		
		digitalWrite(LATCH_CLOCK, HIGH);
  		digitalWrite(LATCH_CLOCK, LOW);					//Latch the shift register.
		
	}
	
	
	// this statement needs to be conditionally executed at a slower time interval!
	
	// We need a TIMER!
	// delay(500);  // this statement will block your loop from proceeding to the next iteration.  BAD IDEA!!!
	
	// Use a ASYNC / NON_BLOCKING timer method.
	if( startTime == 0 )
	{
		startTime = millis();  // 5000
	}
	else
	{
		if( millis() - startTime > ROLLING_DELAY )
		{
			windowPointer++;
			startTime = 0;
		}		
	}
   	
}

And you have not told us what the errors were.

Dunno what you problem is, but you have pin-initialization outside "setup" and you do not call "init()" in "main()" before "setup()" so the hardware is never properly initialized, but that are only minor issues compared to the arrays floating around without any attachment to a declaration.

Where did you find this code, and what made you think it would be useful?

This is what it shows

sketch_feb24a:1:10: fatal error: C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/????: Invalid argument

#include <????> // some Arduino-specific libraries are pre-included. They can be picked from within the Library tab in Arduino IDE.

      ^~~~~~

compilation terminated.

exit status 1

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/????: Invalid argument

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

i made this code for a project

Can you compile the built-in Blink example?

i made this code for a project

Then can you explain why you chose to write this, since that is part of the problem?

// The two scripting functions prototyped right here.  Also hidden.
void setup();
void loop();

//**All other prototypes and global variables are added here


//this section is completely hidden in the back scene of Arduino C Scripting Environment
void main()
{	

What do you mean by the comments regarding "the Arduino C Scripting Environment"?

whats that?

In Arduino UI, it is under File/Examples/01. Basics/Blink

If Blink compiles and loads on your board, then your environment is working.

What Arduino are you using?

Your code has so many errors I'm not sure where to start. I would suggest you try to compile a sample such as Blink in order to verify your IDE and installation is set up properly. I'm afraid you have attempted a project prematurely since you have made fundamental mistakes in the C++ language as well as the Arduino environment.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink

1 Like

so there shouldnt be void?

Did you write this code?

Here is a version of the sketch that actually compiles after having fixed a number of syntax errors and semantic problems.

#include <stdio.h> // some Arduino-specific libraries are pre-included.  They can be picked from within the Library tab in Arduino IDE.
const byte SERIAL_CLOCK = 12; // shifts data into shift registers when pulsed (SRCLK)
const byte LATCH_CLOCK  = 11; // releases shift register data to LED matrix when pulsed (RCLK)
const byte SERIAL_DATA = 10; // data line for the shift registers 
const byte DEMUX_A = 7;
const byte DEMUX_B = 8;
const byte DEMUX_C = 9;

/*
  - Function Name: start()
  - Purpose: Initialization Sequence for Arduino Embedded Target

  - Input(s):   Variable Name Variable Type Purpose
          No input

  - Output:   Return Type
            no return type required
*/

const int BUF_LEN = 200;
const int STR_LEN = 30;    //this means I only can support up to 15 characters pre-drawn

char myLEDDisplayBuffer[6][BUF_LEN] =  // this is my 6x120 LED array display buffer
  // the first 6x6 section of this buffer will be filled by
{
  {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
  {'1', '1', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', } ,
  {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
  {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
  {'1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', } ,
  {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', }
};

char string[STR_LEN] = "ESE!";  // {'E', 'S', 'E', '!', '\0'}

char charE[6][6] =
{
  {'1', '1', '1', '1', '1', '1'} ,
  {'1', '1', '0', '0', '0', '0'} ,
  {'1', '1', '1', '1', '1', '1'} ,
  {'1', '1', '1', '1', '1', '1'} ,
  {'1', '1', '0', '0', '0', '0'} ,
  {'1', '1', '1', '1', '1', '1'}
};

char charS[6][6] =
{
  {'1', '1', '1', '1', '1', '1'} ,
  {'1', '1', '0', '0', '0', '0'} ,
  {'1', '1', '1', '1', '1', '1'} ,
  {'1', '1', '1', '1', '1', '1'} ,
  {'0', '0', '0', '0', '1', '1'} ,
  {'1', '1', '1', '1', '1', '1'}
};

char puncExcl[6][3] =
{
  {'1', '1', '1'} ,
  {'1', '1', '1'} ,
  {'1', '1', '1'} ,
  {'1', '1', '1'} ,
  {'0', '0', '0'} ,
  {'1', '1', '1'}
};

int windowPointer = 0;

const unsigned ROLLING_DELAY = 500;
unsigned long startTime = 0;


void assembleString()
{
  // need an assmebly pointer
  int pointer = 0;

  for (int i = 0; i < STR_LEN; i++)
  {
    if (string[i] == 'E')
    {
      // load the E pattern using nested for-loop
      for (int j = 0; j < 6; j++) // row
      {
        for (int k = 0; k < 6; k++) //col
        {
          myLEDDisplayBuffer[j][k + pointer] = charE[j][k];
        }
      }

      // increase my pointer 6 + 1 unit
      pointer += 7;

    }
    else if (string[i] == 'S')
    {
      // load the S pattern using nested for-loop
      for (int j = 0; j < 6; j++) // row
      {
        for (int k = 0; k < 6; k++) //col
        {
          myLEDDisplayBuffer[j][k + pointer] = charS[j][k];
        }
      }

      // increase my pointer 6 + 1 unit
      pointer += 7;
    }
    else if (string[i] == '!')
    {
      // Load the ! pattern using nested for-loop
      // increase my pointer 3 + 1 unit
    }

  }

}


void setup()  // function, ONLY RUN ONCE
{
  // put your setup code here, to run once:
  //initalizes pin outputs
  pinMode(SERIAL_CLOCK, OUTPUT);
  pinMode(LATCH_CLOCK, OUTPUT);
  pinMode(SERIAL_DATA, OUTPUT);

  pinMode(DEMUX_A, OUTPUT);
  pinMode(DEMUX_B, OUTPUT);
  pinMode(DEMUX_C, OUTPUT);

  assembleString();
}  // myOtherIndex will be destroyed....


/*
  - Function Name: loop()
  - Purpose: The Master Program Loop (Game Loop) Arduino Embedded Target, repeats forever

  - Input(s):   Variable Name Variable Type Purpose
          No input

  - Output:   Return Type
            no return type required
*/

void loop() //function
{
  // put your main code here, to run repeatedly:


  // the way to roll the display / move the sliding window (mask) is to add the "scanner offset"
  //  i.e. the windowPointer...
  /*
    {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
    {'1', '1', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', } ,
    {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
    {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', } ,
    {'1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', } ,
    {'1', '1', '1', '1', '1', '1', '0', '1', '1', '1', '1', '1', '1', '0', }
  */
  // question... what would happen if windowPointer > 8 (e.g. 10)

  // because windowPointer is constantly increased for every program iteration, at one point, windowPointer + col > BUF_LEN
  // (col + windowPointer) % BUF_LEN  (e.g. col: [0 .. 5], windowPointer: 10, BUF_LEN = 14)
  //  [10] % 14 = 10
  //  [11] % 14 = 11
  //  [12] % 14 = 12
  //  [13] % 14 = 13
  //  [14] % 14 = 0
  //  [15] % 14 = 1

  // modulus with BUF_LEN on the col index will ensure that myLEDDisplayBuffer becomes a CIRCULAR BUFFER

  // this part needs to be executed as fast as possible
  for (int row = 0; row < 6; row++)
  {
    // 1. Send the corresponding ABC selection signals to the DEMUX to turn on the row indexed by the variable "row" in the for loop.

    // 2. load all LED bits to the LED column shift register bank
    for ( int col = 0; col < 6; col++)
    {
      if ( myLEDDisplayBuffer[row][ (col + windowPointer) % BUF_LEN ] == '0' )
        digitalWrite(SERIAL_DATA, HIGH);    // digital write HIGH to the Serial Data!
      else
        digitalWrite(SERIAL_DATA, LOW);     // digital write LOW to the serial data.

      digitalWrite(SERIAL_CLOCK, HIGH);      // clock the shift register once!
      digitalWrite(SERIAL_CLOCK, LOW);
    }

    digitalWrite(LATCH_CLOCK, HIGH);
    digitalWrite(LATCH_CLOCK, LOW);         //Latch the shift register.
  }


  // this statement needs to be conditionally executed at a slower time interval!

  // We need a TIMER!
  // delay(500);  // this statement will block your loop from proceeding to the next iteration.  BAD IDEA!!!

  // Use a ASYNC / NON_BLOCKING timer method.
  if ( startTime == 0 )
  {
    startTime = millis();  // 5000
  }
  else
  {
    if ( millis() - startTime > ROLLING_DELAY )
    {
      windowPointer++;
      startTime = 0;
    }
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.