Flash rate change not working!

Trying to change the rate at which an LED is flashing by using an if statment. it is not working... here is my code ... any help?? what did i do wrong??

/* flashing one LED at two different rates... Feed 5v to pin 4 ... the flash rate will slow down. */

const int slowdown = 4; const int ledPin = 13; int t1 = 35; int t5 = 500;

void setup(){ pinMode(slowdown, INPUT); pinMode(ledPin, OUTPUT);


slowflash(); }

void loop(){ digitalRead(slowdown); if(slowdown == HIGH){ slowflash(); } else{ fastflash(); } }

void fastflash(){ digitalWrite(ledPin, HIGH); delay(t1); digitalWrite(ledPin, LOW); delay(t1); }

void slowflash(){ digitalWrite(ledPin, HIGH); delay(t5); digitalWrite(ledPin, LOW); delay(t5); }

Try changing

digitalRead(slowdown); if(slowdown == HIGH)


if(digitalRead(slowdown) == HIGH)

  if(slowdown == HIGH){

This code does NOT save the value from digitalRead(). slowdown is the pin number

You need to save the value to a variable - for example

byte buttonVal = digitalRead(slowdown);
  if(buttonVal == HIGH){