0

Hey guys I'm doing a beginners project 8x8 matrix and I have some errors when compiling

The Errors are;

  • MyBlink:0: error: 'Instance' does not name a type
  • MyBlink.cpp: In function 'void loop()':

-MyBlink:40: error: 'row1' was not declared in this scope

 Instance code:
//the pin to control ROW 
const int row1 = 2; // the number of the row pin 9 
const int row2 = 3; // the number of the row pin 14 
const int row3 = 4; // the number of the row pin 8 
const int row4 = 5; // the number of the row pin 12 
const int row5 = 17; // the number of the row pin 1 
const int row6 = 16; // the number of the row pin 7 
const int row7 = 15; // the number of the row pin 2 
const int row8 = 14; // the number of the row pin 5 
//the pin to control COl 
const int col1 = 6; // the number of the col pin 13 
const int col2 = 7; // the number of the col pin 3 
const int col3 = 8; // the number of the col pin 4 
const int col4 = 9; // the number of the col pin 10 
const int col5 = 10; // the number of the col pin 6 
const int col6 = 11; // the number of the col pin 11 
const int col7 = 12; // the number of the col pin 15 
const int col8 = 13; // the number of the col pin 16 
void setup(){ 
int i = 0 ; 
for(i=2;i<18;i++) 
{ 
pinMode(i, OUTPUT); 
} 
pinMode(row5, OUTPUT); 
pinMode(row6, OUTPUT); 
pinMode(row7, OUTPUT); 
pinMode(row8, OUTPUT); 
for(i=2;i<18;i++) { 
digitalWrite(i, LOW); 
} 
digitalWrite(row5, LOW); 
digitalWrite(row6, LOW); 
digitalWrite(row7, LOW); 
digitalWrite(row8, LOW); 
} 
void loop(){ 
int i; 
//the row # 1 and col # 1 of the LEDs turn on 
digitalWrite(row1, HIGH); 
digitalWrite(row2, LOW); 
digitalWrite(row3, LOW); 
digitalWrite(row4, LOW); 
digitalWrite(row5, LOW); 
digitalWrite(row6, LOW); 
digitalWrite(row7, LOW); 
digitalWrite(row8, LOW); 
digitalWrite(col1, LOW); 
digitalWrite(col2, HIGH); 
digitalWrite(col3, HIGH); 
digitalWrite(col4, HIGH); 
digitalWrite(col5, HIGH); 
digitalWrite(col6, HIGH); 
digitalWrite(col7, HIGH); 
digitalWrite(col8, HIGH); 
delay(1000); 
//turn off all 
for(i=2;i<18;i++) { 
digitalWrite(i, LOW); 
} 
delay(1000); 
} 
1

MyBlink:0: error: 'Instance' does not name a type

Once I deleted the line Instance code: on the first line both errors went away.

Cheers

0

The colon is a bit misleading, it is used in C++ to denote inheritance like this:

E.g.

class Form
{
  int _area;

  public Form(area)
  {
    _area = area;
  }
}

class Circle : class Form
...

However, this is not your intention probably.

Also the colon is used for calling base constructors and for labels to go to (goto, never use this).

0

There is typo in your program. Exactly you should comment out the first line of your code. Adding two slashes at the beginning of the first lines.

Instance code:

As this is not a valid syntax for your code. The compiler is not recognizing what are you trying to do. So it generates a second error because everything that comes after may generate an unknown error. Next time try to solve these kind of problems by reading your console log as it describes exactly at which lines the compiler has found an error. You can see that it generates an error at line 0:

Myblink:0:error....

You have multiples​ errors on this program because as i said before sometimes they are generated as a consequence of your previous error. So you should also try to fix your errors from top to bottom.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.