Hey I am following the book 30 arduino projects for the evil genius by simon monk and I am stuck on project 3. I don’t know what is causing the problem, but here is the message:
Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Uno"
Project_03_morse_translator.ino: In function ‘void loop()’:
Project_03_morse_translator.ino:38:5: error: expected ‘}’ before 'else’
Project_03_morse_translator.ino: At global scope:
Project_03_morse_translator.ino:43:1: error: expected declaration before ‘}’ token
Error compiling.
** This report would have more information with**
** “Show verbose output during compilation”**
** enabled in File > Preferences.**
Please help as soon as possible
Thanks
int ledPin = 12;
char* letters[] = {
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", // A-I
".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", // J-R
"...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." // S-Z
};
char* numbers[] = {"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};
int dotDelay = 200;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
char ch;
if (Serial.available())
{
ch = Serial.read();
if (ch >= 'a' && ch <= 'z')
{
flashSequence(letters[ch - 'a']);
}
else if (ch >= 'A' && ch <= 'Z')
{
flashSequence(letters[ch - 'A']);
}
else if (ch >= '0' && ch <= '9');
{
flashSequence(numbers[ch - '0']);
}
else if (ch == ' ');
{
delay(dotDelay * 4);
}
}
}
void flashSequence(char* sequence)
{
int i = 0;
while (sequence[i] != NULL)
{
flashDotOrDash(sequence[i]);
i++;
}
delay(dotDelay * 3);
}
void flashDotOrDash(char dotOrDash)
{
digitalWrite(ledPin, HIGH);
if (dotOrDash == '.')
{
delay(dotDelay);
}
else
{
delay(dotDelay * 3);
}
digitalWrite(ledPin, LOW);
delay(dotDelay);
}