NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » array?

NerdKits » Forums » Support Forum » array? (4 posts)
March 14, 2011
by crazyflyer
crazyflyer's Avatar

I am newbie to this program. Never wrote C++ program before. I tried to understand from book about array. How to escape after 9 times from Loop? Here the code I wrote. Anyone give me teach me that would be help a lot. thanks.

int ledPin = 13;

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      
}

void loop()
{ 
  digitalWrite (ledPin, HIGH);
  // S (. . .) first dot
  delay(200);
  digitalWrite (ledPin, LOW);
  delay(200);
  digitalWrite (ledPin, HIGH);
  // second dot
  delay(200);
  digitalWrite (ledPin, LOW);
  delay(200);
  digitalWrite(ledPin, HIGH);
  // third dot
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  // 0 (---)
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  //second dash
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  // third dash
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  // S (...) first dot
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(200);
  digitalWrite(ledPin, HIGH);
  // second dot
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(200);
  digitalWrite(ledPin, HIGH);
  // third dot
  delay(200);
  digitalWrite(ledPin, LOW);
  delay(5000);
  // wait five second before we start again

}
March 14, 2011
by Rick_S
Rick_S's Avatar

That appears to be arduino code, not standard avr-gcc code. You'd need to re-write it in standard c to be able to use it on the nerdkit.

Rick

March 14, 2011
by crazyflyer
crazyflyer's Avatar

what is different between arduino code and avr-gcc code?

March 14, 2011
by Rick_S
Rick_S's Avatar

Arduino is a specific hardware/software solution. avr-gcc is a free c compiler for atmel avr micro-controllers. Arduino uses a language called processing that is built around c++. Arduino code will run on the same type microcontroller used in the nerdkit but it would have to be compiled first with the arduino software then transferred manually.

If you are just beginning, I would suggest you put arduino out of your mind for now and concentrate on the nerdkit guide and provided examples. Then look over the tutorials on the website. Search the forum, look at the example code you can find there as well. Soon, you'll find yourself starting to grasp c.

Rick

Post a Reply

Please log in to post a reply.

Did you know that SPDT stands for "Single Pole, Double Throw"? Learn more...