Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Exhibition / Re: sos light using while statements on: December 14, 2009, 08:02:50 am
well thank you for your help im looking into your method now
2  Forum 2005-2010 (read only) / Exhibition / Re: sos light using while statements on: December 13, 2009, 07:12:26 pm
to your question about what is and is not working the program is now working but i was wondering if there was a cleaner shorter way.
3  Forum 2005-2010 (read only) / Exhibition / Re: sos light using while statements on: December 13, 2009, 07:06:50 pm
Well unfortunately the loop code did not work for some reason that is why i used the goto because i tried to run it on my arduino but it did not work.

I like your suggestion but i haven't gotten as far as that yet
but it sounds like a good thing to to next.

thanks!
4  Forum 2005-2010 (read only) / Exhibition / sos light using while statements on: December 13, 2009, 05:02:13 pm
hi new member and im just starting to learn about the arduino's capability's.

I was looking at the blinking light tutorial and thought I ought to make something like it but a little more complex.

Code:
/*
 By: Z3R0 C001
 Date: Sunday, Dec, 13, 2009
 Discription: A morse code SOS program using while statements.
 */

int ledpin = 13; //LED CONNECTED TO PIN 13
int count = 0; // first interger to count slow blinks
int selo = 0; //second int to count fast blinks

void setup()  {

  //makes the pin13 the output
  pinMode(ledpin, OUTPUT);
}

void loop()
{
label:
  while (count < 1) /* this while loop makes the pause between the last quick flash to the first long flash the same length as the rest of the pauses between the other long flashes */

  {    
    delay(300);
    digitalWrite(ledpin, HIGH); //turns led pin on
    delay(900);
    digitalWrite(ledpin, LOW);
    delay(500);
    ++count;
  }
  while (count >= 1 && count < 3) // second and third long flash
  {
    ++count;
    digitalWrite(ledpin, HIGH); //turns led pin on
    delay(900);
    digitalWrite(ledpin, LOW);
    delay(500);
  }
  while (count = 3 && selo < 3) // short flashes
  {
    ++selo;
    digitalWrite(ledpin, HIGH); //turns led pin on
    delay(200);
    digitalWrite(ledpin, LOW);
    delay(200);
  }
  
  count = 0; //resetting the variables
  selo = 0;
  goto label; //starts the while loops over
}

now i was trying to make this simpler and much smaller but i gave up after a bit   smiley-grin

any suggestions?
Pages: [1]