Go Down

Topic: if statement not working on new Uno board (Read 535 times) previous topic - next topic


I am thinking I just have a bad board.  I just bought it and am going through a tutorial to learn how to use it.  This is just making the led on the board blink with an increasing on and off time.  That part works, but once I add an "if" statement to reset the counter once the delay has reached 3000 the delay period no longer increases, it continues to blink fast.  I've tried increasing the trigger from 3000 to 100000 without any difference.  I've reversed it like this: if (10000 < delayPeriod) delayPeriod = 100 and it hasn't made a difference.  Below is what I'm trying to use:


int ledPin = 13;
int delayPeriod = 100;

void setup()
  pinMode(ledPin, OUTPUT);

void loop()
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin, LOW);
  delayPeriod = delayPeriod + 100;
  if (delayPeriod = 100000) delayPeriod = 100;

I have also tried:  if (delayPeriod > 10000)
delayPeriod = 100

and there wasn't any difference.  Am I missing something or could it just be a bad board?


if (delayPeriod = 100000) delayPeriod = 100;

if (delayPeriod == 100000) delayPeriod = 100;
Mrs Drew
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.


int's only go to 65,535.

unsigned long delayperiod;

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Thank you both.  After using the double = sign it started working, even using the greater than sign works now.  if delayPeriod > 3000 was not working before, but now it does.

Go Up