Go Down

Topic: Morse code error (Read 468 times) previous topic - next topic

meddyliol

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

JimboZA

The error tells you that this:

Code: [Select]
voidsetup() {

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

Code: [Select]
void setup() {
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

meddyliol

Brilliant, how stupid of me. Thanks a lot for that.

Brian   :)  :)

Go Up