Arduino Forum

Using Arduino => Programming Questions => Topic started by: meddyliol on May 18, 2015, 01:12 pm

Title: Morse code error
Post by: meddyliol on May 18, 2015, 01:12 pm
Could someone please let me know what is wrong with this code? I have looked and looked but cannot see why an error is generated.

Code: [Select]
// Project 2 - SOS Morse Code Signaler
// LED connected to digital pin 10
int ledPin = 10;
// run once, when the sketch starts

voidsetup() {
   // sets the digital pin as output
   pinMode(ledPin, OUTPUT);
}
// run over and over again
void loop() {
// 3 dits
for (int x=0; x<3; x++) {
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
delay(100);
}
// 100ms delay to cause slight gap between letters
delay(100);
// 3 dahs
for (int x=0; x<3; x++) {
digitalWrite(ledPin, HIGH);
delay(400);
digitalWrite(ledPin, LOW);
delay(100);
}
// 100ms delay to cause slight gap between letters
delay(100);
// 3 dits again
  for (int x=0; x<3; x++) {
  digitalWrite(ledPin, HIGH);
  delay(150);
  digitalWrite(ledPin, LOW);
  delay(100);
}
  // wait 5 seconds before repeating the SOS signal
  delay(5000);
}/code]

Error Message:

Arduino: 1.6.3 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

sketch_may18b.ino:5:11: error: ISO C++ forbids declaration of 'voidsetup' with no type [-fpermissive]
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Thanks

Brian
Title: Re: Morse code error
Post by: JimboZA on May 18, 2015, 01:13 pm
The error tells you that this:

Code: [Select]
voidsetup() {

.... is wrong. It needs a space:

Code: [Select]
void setup() {
Title: Re: Morse code error
Post by: meddyliol on May 18, 2015, 01:27 pm
Brilliant, how stupid of me. Thanks a lot for that.

Brian   :)  :)