how to stoop serial spaming

hi guys how do you print once to serial only when changing states

i think i need if "this" is "this" and was previously "this" statement but i cant figure out how to write it properly

int lowswitch = 3 ; // pin for low level float switch
int switchup = 0 ; // state of the low level float switch
void setup() {
pinMode(lowswitch,INPUT_PULLUP); // set pin as input with internal pull up
Serial.begin(9600); 
}

void loop() {
 int switchup = digitalRead(lowswitch); //read the state of the float switch
 // print out the value you read:
    if (!switchup) {
        switchup = 1;
        Serial.print("low");
        Serial.println();
    } else if(switchup) {
        switchup = 0;
        Serial.print("high");
        Serial.println();
       
    }
}

right now its flooding my serial with either low or high and i just want it to print if it was low and it changed to high or viceversa

Have a look at the "State Change" example in the IDE. It's pretty well explained there but if you still don't understand google it and there are more than a few writeups that explain it in more detail.

Imagine you have a boolean variable called switchStateChanged then you printing could be based on that

if (switchStateChanged == true) {
   Serial.print......

}

I will leave it as a homework exercise to figure out how to set the value of switchStateChanged

...R

c0ryp1: i think i need if "this" is "this" and was previously "this" statement but i cant figure out how to write it properly

The answer lies in... i think i need if "this" is "this" and was previously "[u]that[/u]"

It is if this time is not equal to last time. You have to remember last time in a variable.

if(switchup != lastSwitchup) { Serial.print("change ");}
lastSwitchup = switchup;

The lastSwitchup should be either a global variable or a static one.