Can someone help me figure out why this is happening ? My directory structure follows the format in the readmes in lib and include. Namely, all my headers are in src and I include them in the relevant classes. So I am not sure what is going wrong, and would appreciate help.
I have 2 classes, Wheel and Robot.
Robot has Wheels as properties:
Robot.h
class Robot{
public:
Robot();
private:
Wheel frontWheels[2]; //instantiate a wheel obj. using default c-tor
Wheel backWheels[2]; //instantiate a wheel obj. using default c-tor
public:
void turn(int angle);
void moveFwd();
void moveBackwd();
private:
//
};
#endif
Robot Constructor:
Robot::Robot(){
//instantiate front wheels
for (int i = 0; i < 2; i ++){
Wheel w = Wheel(22 + i, 23 + i, 2+i);
this->frontWheels[i] = w;
}
for (int i = 0; i < 2; i ++){
Wheel w = Wheel(26 + i, 27 + i, 4+i);
this->backWheels[i] = w;
}
}//end contsructor
main.cpp
#include <Arduino.h>
#include "Robot.h"
Robot u0;
void setup() {
Serial.begin(9600);
}
void loop() {
u0.moveFwd();
delay(1000);
u0.moveBackwd();
}
Wheel:
the wheel class just sets up the infrastructure for motors. it has been unit tested and verified.
#include "Wheel.h"
Wheel::Wheel(uint p1, uint p2, uint enable){
pinMode(p1, OUTPUT);
pinMode(p2, OUTPUT);
pinMode(enable, OUTPUT);
this->pin1 = p1; this->pin2 = p2; this->enable = enable;
}
void Wheel::turnFwd(){
digitalWrite(this->pin1, HIGH);
digitalWrite(this->pin2, LOW);
}
void Wheel::turnBackwd(){
digitalWrite(this->pin2, HIGH);
digitalWrite(this->pin1, LOW);
}