ISO C++ error....

When I try to compile my code I get this error:

In function 'void loop()':
error: ISO C++ forbids comparison between pointer and integer

How do I fix it?
This is my code:

/* DANGa Signals MK1
Made on BoArduino V2.0
Will Be adapted for use on Custom Board
See JPEGs
Layout is as follows: */

int redPin = 9;
int redOn;
int orangePin = 10;
int orangeOn;
int greenPin = 11;
int greenOn;
int switchPin = 12;
int lastOn = 0;
int lastOn2 = 0;

void setup(){
pinMode(redPin, OUTPUT);
pinMode(orangePin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(switchPin, INPUT);
redOn = 1;
digitalWrite(redPin, HIGH);
lastOn = 0;
}

void loop(){
if (switchPin == HIGH){
if (lastOn == "0"){
digitalWrite(redPin, LOW);
digitalWrite(orangePin, HIGH);
lastOn = lastOn2;
//offYet();
}
else{
digitalWrite(greenpinPin, LOW);
digitalWrite(orangePin, HIGH);
lastOn = lastOn2;
offYet();
}
}

}

void offyet(){
if (switchPin == LOW){
if (lastOn == ""0""){
digitalWrite(orangePin, LOW);
digitalWrite(greenPin, HIGH);
//loop();
}
else{
digitalWrite(orangePin, LOW);
digitalWrite(redPin, HIGH);
}
}
else{
offYet();
}
}

In a couple of places you have this:

if (lastOn == "0"){

when you should have this (without the quotes):

if (lastOn == 0){

I suspect you have some other problems too (for instance lastOn2 is never updated after it's declared) but I bet the quotes thing is what's stopping your code compiling.

Andrew

thanks
I fixed it after looking deeper.... Sorry.
Now when I put the modified program onto my Boarduino then it randomly changes the. signal colours.
Any bright ideas? Do you want the new source code?

It's difficult to see what you are trying to do, particularly because the there is no indenting of the code you posted. Try posting your code in a code block (use the # icon).

I do see that you have a recursive call that may not be intended, offyet() seems to call itself if switchpin is high, I doubt this is what you want to do.

It would be easier to provide advice if you described what function you want your code to perform. It looks like you want to toggle the state of a couple of leds depending on the state of switchpin, but I am not sure.

what I want to do is make a model railway signal system that when a magnet on a train passes over the reed switch next to the signal then the signal colour goes to amber when the magnet is HIGH but when it reads LOW then I need it to go to the opposite colour that it started with. So if the colour is Red then the train goes over, the colour goes to amber but when the train goes away it goes to green.

Here is some pseudo code that I hope you can flesh out into working arduino code that does what you want

static boolean Red
static boolean Green

Setup()
Red= true;
Green= false;

Toggle()
Red = !Red;
Green = !Green;
digitalWrite(Led1,Red);
digitalWrite(Led2,Green);

Loop()
while(switch is low)
delay; // do nothing while switch is low
while(switch is high) // you may need to debounce the switch !!
digitalWrite(AMBER, HIGH);

digitalWrite(AMBER, LOW);
Toggle();

thank you