Please find bellow a code I have on my system written by my predecessor .. I am brand new to Arduino and getting to grips with the basics but I can't find what is wrong with this code.
I get the error <
C:\Users\jim\AppData\Local\Temp\build8007785878879012402.tmp/core.a(main.cpp.o): In function main': C:\Users\jim\Desktop\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/main.cpp:34: undefined reference to
setup'
collect2.exe: error: ld returned 1 exit status
Error compiling.
I have an Uno and a digispark attiny85 board (I believe this code was previously used on an attiny although the pin number suggests not this instance...
<// Program to convert a word or phrase into morse code and transmit through digital Pin 13, which can in turn be attached to an LED or relay
char c ; //Switch case variable
int i = 0; //initialise i to 0
char arr[] = "is there anybody out there?"; //character array where message to be converted is stored
int ledPin = 13; //initialise output on pin 13
int dotTime = 200; //duration in ms of value T
void sendDot() {
digitalWrite(ledPin, HIGH);
delay(dotTime); //function to Transmit a "Dot"
digitalWrite(ledPin, LOW);
delay(dotTime);
}
void sendDash() {
digitalWrite(ledPin, HIGH);
delay(3 * dotTime); //function to transmit a "Dash" - 3x the length of a Dot
digitalWrite(ledPin, LOW);
delay(dotTime);
}
void sendShortGap() {
delay(2 * dotTime); //ShortGap sent between each letter
}
void loop() {
for (i = 0; i < sizeof(arr); i++)
{
c = arr ; // Initializing each element separately
- switch (c) {*
_ case ' ' : delay(7 * dotTime); break;_ - case 'a' : flash("01"); break;*
- case 'b' : flash("1000"); break;*
- case 'c' : flash("1010"); break;*
- case 'd' : flash("100"); break;*
- case 'e' : flash("0"); break;*
- case 'f' : flash("0010"); break;*
- case 'g' : flash("110"); break;*
- case 'h' : flash("0000"); break;*
- case 'i' : flash("00"); break;*
- case 'j' : flash("0111"); break;*
- case 'k' : flash("101"); break;*
- case 'l' : flash("0100"); break;*
- case 'm' : flash("11"); break;*
- case 'n' : flash("10"); break;*
- case 'o' : flash("111"); break;*
- case 'p' : flash("0110"); break;*
- case 'q' : flash("1101"); break;*
- case 'r' : flash("010"); break;*
- case 's' : flash("000"); break;*
- case 't' : flash("1"); break;*
- case 'u' : flash("001"); break;*
- case 'v' : flash("0001"); break;*
- case 'w' : flash("011"); break;*
- case 'x' : flash("1001"); break;*
- case 'y' : flash("1011"); break;*
- case 'z' : flash("1100"); break;*
- case 'A' : flash("01"); break;*
- case 'B' : flash("1000"); break;*
- case 'C' : flash("1010"); break;*
- case 'D' : flash("100"); break;*
- case 'E' : flash("0"); break;*
- case 'F' : flash("0010"); break;*
- case 'G' : flash("110"); break;*
- case 'H' : flash("0000"); break;*
- case 'I' : flash("00"); break;*
- case 'J' : flash("0111"); break;*
- case 'K' : flash("101"); break;*
- case 'L' : flash("0100"); break;*
- case 'M' : flash("11"); break;*
- case 'N' : flash("10"); break;*
- case 'O' : flash("111"); break;*
- case 'P' : flash("0110"); break;*
- case 'Q' : flash("1011"); break;*
- case 'R' : flash("010"); break;*
- case 'S' : flash("000"); break;*
- case 'T' : flash("1"); break;*
- case 'U' : flash("001"); break;*
- case 'V' : flash("0001"); break;*
- case 'W' : flash("011"); break;*
- case 'X' : flash("1001"); break;*
- case 'Y' : flash("1011"); break;*
- case 'Z' : flash("1100"); break;*
- case '0' : flash("11111"); break;*
- case '1' : flash("01111"); break;*
- case '2' : flash("00111"); break;*
- case '3' : flash("00011"); break;*
- case '4' : flash("00001"); break;*
- case '5' : flash("00000"); break;*
- case '6' : flash("10000"); break;*
- case '7' : flash("11000"); break;*
- case '8' : flash("11100"); break;*
- case '9' : flash("11110"); break;*
- case '.' : flash("010101"); break;*
- case ',' : break;*
- default : delay(1000); break;*
- }*
- }*
}
void flash(char x[]) { - for (int i = 0; i < strlen(x); i++) {*
_ if (x == '1') {_
* sendDash();*
* }*
* else {*
* sendDot();*
* }*
* }*
* sendShortGap();*
}
>