Writing my own libraries ERROR

So I’ve written in a variety of languages, so I understand the concepts, but I’m fairly new to C++. I’m trying to write my own libraries for a project I’m working on developing some some things for the Arduino. But I keep getting an error that my variable is not declared in the current scope. I’ve read the “how to” on libraries here (Arduino - LibraryTutorial), and thought that if I declared my variables in the class, and then populated them when the library is initialized, then those variables would be populated throughout the rest of the functions in my library.

All I’m trying to do here is initialize the pins for a 7 segment display, and then use those same pins when other functions are called upon. Here take a look:

SevenSeg.h

#ifndef SevenSeg_h
#define SevenSeg_h

#include "Arduino.h"


class SevenSeg
{
  
	public:
    
		SevenSeg(int sevsegA, int sevsegB, int sevsegC, int sevsegD, int sevsegE, int sevsegF, int sevsegG, int sevsegP);
    
		void displayChar(String Char);
    
		void turnOff();
 
	private:
    
		int _sevsegA;
		int _sevsegB;
		int _sevsegC;
		int _sevsegD;
		int _sevsegE;
		int _sevsegF;
		int _sevsegG;
		int _sevsegP; 
};

#endif

SevenSeg.cpp

SevenSeg::SevenSeg(int sevsegA, int sevsegB, int sevsegC, int sevsegD, int sevsegE, int sevsegF, int sevsegG, int sevsegP)
{
  
	pinMode(sevsegA, OUTPUT);
	pinMode(sevsegB, OUTPUT);
	pinMode(sevsegC, OUTPUT);
	pinMode(sevsegD, OUTPUT);
	pinMode(sevsegE, OUTPUT);
	pinMode(sevsegF, OUTPUT);
	pinMode(sevsegG, OUTPUT);
	pinMode(sevsegP, OUTPUT);
	_sevsegA = sevsegA;
	_sevsegB = sevsegB;
	_sevsegC = sevsegC;
	_sevsegD = sevsegD;
	_sevsegE = sevsegE;
	_sevsegF = sevsegF;
	_sevsegG = sevsegG;
	_sevsegP = sevsegP;
}



void SevenSeg::displayChar(String Char)

{

	//Conditions for displaying segment a
 
	if(Char!="1" && Char != "4")
 
	digitalWrite(_sevsegA,HIGH);
 
 

	//Conditions for displaying segment b
 
	if(Char != "5" && Char != "6" && Char !="C" && Char !="E" && Char !="F")
 
	digitalWrite(_sevsegB,HIGH);
 
 

	//Conditions for displaying segment c
 
	if(Char !="2" && Char !="C" && Char !="E" && Char !="F")
 
	digitalWrite(_sevsegC,HIGH);
 
 

	//Conditions for displaying segment d
 
	if(Char != "1" && Char !="4" && Char !="7" && Char !="A" && Char !="F")
 
	digitalWrite(_sevsegD,HIGH);
 
 

	//Conditions for displaying segment e 
 
	if(Char == "2" || Char =="6" || Char == "8" || Char=="0")
 
	digitalWrite(_sevsegE,HIGH);
 
 
	
	//Conditions for displaying segment f
 
	if(Char != "1" && Char !="2" && Char!="3" && Char !="7")
 
	digitalWrite(_sevsegF,HIGH);

 

	//Conditions for displaying segment g
 
	if (Char!="0" && Char!="1" && Char !="7" && Char !="C" && Char !="D")
 
	digitalWrite(_sevsegG,HIGH);

 
	
	//The only way to tell some of the letters apart from numbers is that when it's a Letter, the DP will be on (example, both B and 8, illuminate the same segments, so B will have the DP on.)
 
	if (Char=="A" || Char=="B" || Char=="C" || Char=="D" || Char=="E" || Char=="F")
 
	digitalWrite(_sevsegP,HIGH);


}


void SevenSeg::turnOff()

{
  
	digitalWrite(_sevsegA,LOW);
  
	digitalWrite(_sevsegB,LOW);
  
	digitalWrite(_sevsegC,LOW);
  
	digitalWrite(_sevsegD,LOW);
  
	digitalWrite(_sevsegE,LOW);
  
	digitalWrite(_sevsegF,LOW);
  
	digitalWrite(_sevsegG,LOW);
  
	digitalWrite(_sevsegP,LOW);

}

My Project File

#include "Arduino.h"
#include "SevenSeg.h"

SevenSeg sevenSeg(22,23,24,25,26,27,28,29);

void setup() {
}

void loop() {
  for(int i=0;i<10;i++)
  {
    sevenSeg.displayChar("A");
    delay(1000);
    sevenSeg.turnOff();
    delay(100);
  }
}

I’m just using the “A” as a test. And here’s the error I get:

SevenSeg.cpp:121:15: error: '_sevsegP' was not declared in this scope

  digitalWrite(_sevsegP,LOW);

               ^

exit status 1
Error compiling.

So it appears that when the “turnOff” function is called, that it doesn’t recongnize that my private variable “_sevsegP” is not available to the function.

Can anyone tell me what I’m missing? Thanks.

Sevenseg.cpp also needs to #include the header file.

void SevenSeg::displayChar(String Char)

Why are you wasting resources to use a String to hold a single character. Just let the function take a char.

The hardware may not be ready when your constructor is invoked. You should NOT be diddling with pins in the constructor.

You should have a begin() method where you diddle with the hardware.

If the compiler agrees that _sevsegA, _sevsegB, etc. are accessible, then there is something different between your header file and your source file.

Create a zip file and attach it here, of the code that you are actually compiling.