Fairly new to Arduino, and its been a few years since c++, but....
I get the error messages below. It doesn't say what line but it seems to be complaining about my transition() function:
Traffic:-1: error: variable or field 'transition' declared void
Traffic:-1: error: 'TLight' was not declared in this scope
Traffic:-1: error: 'toRed' was not declared in this scope
Traffic:-1: error: 'TLight' was not declared in this scope
Traffic:-1: error: 'toGreen' was not declared in this scope
Traffic:-1: error: expected primary-expression before 'int'
Does the arduino version of the compiler support pass by reference, or, what am I missing...
Thanks!! Having a great time with this with my nieces!
John
class TLight {
private:
int rP,yP,gP;
int doubleRedP;
public:
TLight(int red, int yellow, int green, int extraRed)
{
rP = red; yP = yellow; gP = green; doubleRedP = extraRed;
pinMode(rP, OUTPUT);
pinMode(yP, OUTPUT);
pinMode(gP, OUTPUT);
}TLight(int red, int yellow, int green)
{
rP = red; yP = yellow; gP = green; doubleRedP = -1;
pinMode(rP, OUTPUT);
pinMode(yP, OUTPUT);
pinMode(gP, OUTPUT);
}void red() { set(HIGH, LOW, LOW); }
void yellow(){ set(LOW, HIGH, LOW); }
void green() { set(LOW, LOW, HIGH); }private:
void set(int rV, int yV, int gV){
digitalWrite(rP, rV);
digitalWrite(yP, yV);
digitalWrite(gP, gV);
if (doubleRedP >= 0)
digitalWrite(doubleRedP, rV);
}
};TLight t1( 9, 11, 13);
//TLight t2( 5,6,7);void transition( TLight & toRed, TLight& toGreen, int yellowDelay)
{
toRed.yellow();
delay(yellowDelay);
toRed.red();
toGreen.green();
}// The setup() method runs once, when the sketch starts
void setup() {
t1.green();
// t2.red();
}void loop()
{
//transition(t1, t2, 1000); delay(4000);
//transition(t2, t1, 1000); delay(4000);
}