Is there a better way to what I'm doing?

The short and predicted answer is yes.

I can't stop to explain what I mean, I'm on a roll otherwise.

//runtime modes
#define REBOOT    0
#define LOWPOWER  1
#define STARTUP   2
#define STANDBY   3
#define STOPPED   4
#define MOVING    5
#define DEBUG     6 
#define VIRTUAL   7
#define SHUTDOWN  8
#define ERROR     9

//move types
#define UP    0
#define DOWN  1
#define LEFT  2
#define RIGHT 3
#define STAND 4
#define SIT   5

In my defines I create a name for, say a run-time level, and then an arbitrary number.

Is there any sense to doing this?

I ask because I'm not actually sure why my brain is telling me to define these states like this, I just keep falling back on doing it.

Can someone with a little knowledge give some insight on my behaviour?

Lot easier to follow words in the code vs just numbers.
"I'm in State 3 - what's that one doing?"
vs
"I'm in Standby - now I'm waiting for an input to kick me into Moving."

Using enums, you can restrict the application to use only the defined values, which have default numbers assigned, based on the position in the enum. Far better than name = value substitution at compile time.

One way, use appropriate names for your application:

//define the available machine states for this sketch
//add more states as needed
enum States{
stateStart, stateOne, stateTwo, stateThree, stateFour, stateFive};

//mState is "machine State"
States mState = stateStart; //we start out in this machine state

.

One way, use appropriate names for your application:

Like stateOne and stateTwo? Are you kidding?

Okay, I don’t know if this is going to help in any way at all, but here’s my main (Quadruped Robot) header file:

//Onyx library creates classes to represent the various functions and systems of the Onyx Robotic Quadruped.
//The current CPU is an arduino-like Chipkit Uno32

#ifndef _Onyx_H
#define _Onyx_H


#if (ARDUINO >= 100)
# include <Arduino.h>
#endif

//-Extra Includes-
#include "SSC32.h"

//Onyx Definitions 
#define baudrate 115200 		//Symbols per second. Default hardware set 115200
#define sscReturn 0	            //Is SSC32 Connected bi-directionally? (default "0" = no)

//Physical Dimensions //all in floating point millimetres accurate to the thousandth
	#define Trochanter_X 61.40
	#define Trochanter_Y 4.34 //CAD Model Incorrect!!

	#define Femur_X 24.29 
	#define Femur_Y 50.78 
	#define Femur   56.29 //The L1 Value

	#define Tibia 41.02
	#define Tarsus 62.00 //Tibia + Tarsus = L2 Value
	
	#define Body_Width 139.72
	#define Body_Length 106.25
//----------------------------------------------------------------------------
//Servo-Power Relay Pin
#define relayServos 27

//Leg Indicator LED Pins
#define iFL 35
#define iFR 34
#define iRR 8
#define iRL 9
    
//-------------------------------------------------------------------------------------------------------------

//On Off Toggle References
#define ON      1
#define OFF     0
#define HIGH    1
#define LOW     0
#define TOGGLE  2

//runtime modes
#define REBOOT    0
#define LOWPOWER  1
#define STARTUP   2
#define STANDBY   3
#define STOPPED   4
#define MOVING    5
#define DEBUG     6 
#define VIRTUAL   7
#define SHUTDOWN  8
#define ERROR     9

//move types
#define UP    0
#define DOWN  1
#define LEFT  2
#define RIGHT 3
#define STAND 4

#define pi 3.14159;

class Onyx {
	private:
		int _mode;
        int _ServoList[12];
		
		void startup();
	public:
		Onyx();
		void setMode(int mode); //sets runtime state
		void listen();
		void reconnectSSC(); //reinitialize SSC instance communication
		
		void newMove(int type);
		void move();
};

class Power {
	private:
		int Main_Relay;
		bool _powerMain; //Power State (ON,OFF)
	public: 
		Power(int Main_Relay);
		void setMainPin(int pin);
		void ToggleMain(int state);
};

class Servo {
	private:
		int _pin;
		bool _isExternal;
		bool _isGroup; //Is the servo part of a group?
		int _groupNumber;
	public: 
		Servo(int pin);
		void move(int pulse);
		void setGroup(int groupNumber);
};

class Leg {
	private:
	float _Trochanter_X;
	float _Trochanter_Y;

	float _Femur_X;
	float _Femur_Y; 
	float _Femur;
	float _L1;
	
	float _Tibia;
	float _Tarsus;
	float _L2;
	
		int _quadrant;
		bool _isGroup;
		
	public: 
		Leg(int index);
};

#endif

My real problem is that I’ve only just recently gotten into programming, so I’m sitting here, bashing my keyboard and typing things trying to get the damn program to compile every once in awhile.

I’m not quite sure I understand how I would how to substitute enums for my current state tracking method.

Here’s the Main CPP file.
(The classes are all contained to one file as my preference)

#include "Onyx.h"

SSC32 SSC;
Power Actuators(relayServos);
Leg FL(0);
Leg RL(12);
Leg FR(16);
Leg RR(28);

Onyx::Onyx() 
: _ServoList {0,1,2,12,13,14,16,17,18,28,29,30} //I literally have no idea why this works 
{
	setMode(LOWPOWER);
}

void Onyx::setMode(int mode)
{
	_mode = mode;
	if(mode==STARTUP)startup();
	if(mode==STANDBY)listen();
	if(mode==SHUTDOWN)Actuators.ToggleMain(OFF);
	if(mode==LOWPOWER)setMode(SHUTDOWN);
	if(mode==REBOOT)startup();
}

void Onyx::reconnectSSC();
{
	Serial.end();
	SSC.begin(baudrate);
	SSC.check();
}

void Onyx::startup()
{
	//moveScope(BODY);
	//move(STAND);
	SSC.newGroup(MOVE);
	for(int i=0; i<12;i++){
		SSC.servoMove(_ServoList[i],1500,1000);
	}
	SSC.executeGroup();
	setMode(STANDBY);
}

void Onyx::listen()
{
	if(Serial.available()>0){
		switch (Serial.read()){
			case 'p':
				Actuators.ToggleMain(TOGGLE);
			break;
			case 's':
			break;
			case 'a':
			
			break;
			case 'd':
			
			break;
		}
	}
	
}

void Onyx::moveBody(int Command) //Move center of mass in direction (UP,DOWN,LEFT,RIGHT)
{
	
}

Power::Power(int Main_Relay)
{
	ToggleMain(OFF);
	setMainPin(Main_Relay);
}

void Power::setMainPin(int pin)
{
	Main_Relay = pin;
	ToggleMain(OFF);
    pinMode(Main_Relay, OUTPUT);
	ToggleMain(_powerMain);
}

void Power::ToggleMain(int state){
	if(state != _powerMain){
		if(state==TOGGLE)ToggleMain(!_powerMain);
		else {
			digitalWrite(Main_Relay,state);
			_powerMain = state;
		}
	}
	else return;
	
}

Leg::Leg(int index)
{
	Servo Coxa(index);
	Servo Knee(index + 1);
	Servo Ankle(index + 2);
}

Leg::setMaster()
{
	if
}

Servo::Servo(int pin)
{
	_pin = pin;
	_isExternal = 1;
}

I’m really trying hard to stay away from the noob-common “HELP I DON’T KNOW WHAT I’M DOING FIX MY CODE”

but… can you? :stuck_out_tongue:

One way, use appropriate names for your application:
@PaulS

Like stateOne and stateTwo? Are you kidding?

This was an example only.
I mentioned that the OP should use appropriate names for his application.

You may have misinterpreted.

Is state tracking really just a preference thing? I mean, it makes sense to me as it stands, I just couldn't describe it to someone. It's my personal style.

However, if I'm doing something INCORRECTLY (not preference based) then I want to know.

I've reviewed a couple different libraries now, they seem to do something (almost exactly) like I'm doing.

Is enums really all that different? and how?

See PaulS reply #2

Have a look at planning and implementing a program.

I am a great believer in meaningful names for everything, and short functions with a single purpose.

I suspect a large number of states (even if suitably named) will be confusing unless the code in which they are used is very carefully organized. Life will be simpler if any part of the code only needs to deal with a few states.

...R

If your code is doing what you want, there really is no reason to change anything. If it isn't, please describe what it is actually doing, and how that differs from what you want.

Is enums really all that different? and how?

A few answers to your question,

florinc:
A few answers to your question,

Dammit, no one here said #define = enums!!!

I know this is the generic "Google it" answer, but jesus thank you!

Edit: I know that enums != defines, but generally they're the same concept.
This was the answer I wanted

SilentDemon555:
Dammit, no one here said #define = enums!!!

I know this is the generic "Google it" answer, but jesus thank you!

Edit: I know that enums != defines, but generally they're the same concept.
This was the answer I wanted

You are correct , #define != enums!!!

How you propose to do similar code (attached) using enum since by definitions enums are NOT numbers / integers and without knowing their position in enum assignment you do not automatically know the value anyway.

Here is #define code

#if DLEVEL > 5
    #define SIGNAL  1
    #if STACKUSE == 1
        #define STACK   200
    #else
        #define STACK   100
    #endif
#else
    #define SIGNAL  0
    #if STACKUSE == 1
        #define STACK   100
    #else
        #define STACK   50
    #endif
#endif