2013年2月26日 星期二

[arduino][Project] Morse code sos


[arduino][Project] Morse code sos



1. Where to download sample code



arduinoevilgenius.com

Go to Download page and select

evil_genius.zip

To download all of project code.



2. Write a code





int ledPin = 13;

int durations[] = {400, 400, 400, 1000, 1000, 1000, 400, 400, 400};



void setup()                    // run once, when the sketch starts

{

  pinMode(ledPin, OUTPUT);      // sets the digital pin as output

}



void loop()                     // run over and over again

{

  for (int j = 0; j < 9; j++)

  {

    flash(durations[j]);

  }

  delay(6000);                  // wait 1 second before we start again

}



void flash(int duration)

{

  digitalWrite(ledPin, 1);

  delay(duration);           

  digitalWrite(ledPin, 0);    

  delay(duration);

}



Reference the video




0 意見:

張貼留言