Using a push button to set value of an int

I have a nano running a wave form 10ms on 95 ms off
I want to incorparate a push button so when I push it it changes the on off times
so before its pressed TON =10 toff =90
when I push the putton ton changes to 5 and toff to 95.

Can I use an if else statement to do this
ie if( pushbutton==HIGH);
Ton =10;
Toff =90;
else
Ton=5;
toff=95;

Would this be the correct way to do it?

That says so long as the button is held HIGH you get 10/90, once you let go it becomes 5/95. If that's what you meant then it's fine.

But more likely you mean that each time you press and release the values will change. If so you need to look at the StateChangeDetection example in the IDE. You need to know when the button BECOMES pressed not just IS pressed.

Steve

That is what I want it I press the putton and hold it ,it changes.
This is my code it compiles ok but what ever the state of the pushbutton pin is the value stays at 10, never =50 .
I can't work out why

int Output =3;

int OutputState=LOW;
unsigned long previousMillis1=0;
long OnTime;// on time of waveform

long OffTime;// off time of waveform
int pushbutton=6

;
void setup() {
// put your setup code here, to run once:
pinMode(Output,OUTPUT);
pinMode(pushbutton,INPUT);
Serial.begin(9600);

}

void loop() {
// put your main code here, to run repeatedly:
unsigned long currentMillis=millis();
if (pushbutton==HIGH
){

OnTime=50;
OffTime=950;
//Serial.print(OnTime);
}else {

OnTime =10;
OffTime= 90;

}
Serial.println(OnTime);
if ((OutputState==HIGH)&&(currentMillis-previousMillis1>=OnTime))
{
OutputState =LOW;
previousMillis1=currentMillis;
digitalWrite(Output,OutputState);
}
else if ((OutputState==LOW)&&(currentMillis-previousMillis1>=OffTime))
{
OutputState=HIGH;
previousMillis1=currentMillis;
digitalWrite(Output,OutputState);
}
}

I assume your button is wired to pin 6, in which case you should replace the following:

if (pushbutton==HIGH)

with:

if (digitalRead(pushbutton) == HIGH)

How is your pushbutton wired? The way you have the pin configured and the way you are testing the input value implies you have the button wired to +5V with a pulldown resistor. Is this the case?

You say:
pushbutton is the number = 6
you never check its state by asking digitalRead()

Please check this basic tutorial here:

this solves your problem

Great thanks for your help . It now works