Hey guys.. Im having some trouble uploading this code.. which I will post down below. Its about a morse code translator.
we_were/we_were.ino: In function 'void loop()':
ino:16:53: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence("-......-..--...--......-..--...-")
ino:17:67: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence("-.-.......-..--.--....--.-.......-..--.--....-");
warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence("-.-......--.-...-...--.....--.-......--.-...-...--.....-");
ino:19:85: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence("-.-..-.-----.-.---....-....-...--.-..-.-----.-.---....-....-...-")
ino:20:101: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence("..-..-...-....-...-----.---.--.-...-..-...-..-...-....-...-----.---.--.-...-..-."
we_were/we_were.ino:21:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence(".-..---..-..---. ");
ino:22:71: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
morseCodeSequence(".--.--......-.-.-..--.-...--.--......-.-.-..--.-..");
ino: In function 'void morseCodeSequence(char*)':
ino:34:26: warning: NULL used in arithmetic [-Wpointer-arith]
while (sequence *!= NULL) *
-
^*
===code====
int ledPin = 13;
//duration of the dot in morse code, this is also the time between the dots and dashes
int dotDelay = 200;
*void setup() *
{ -
// Setup the pin as output*
-
pinMode(ledPin, OUTPUT);*
}
*void loop() *
{
morseCodeSequence("-......-..--...--......-..--...-");//
morseCodeSequence("-.-.......-..--.--....--.-.......-..--.--....-");//
morseCodeSequence("-.-......--.-...-...--.....--.-......--.-...-...--.....-");//
morseCodeSequence("-.-..-.-----.-.---....-....-...--.-..-.-----.-.---....-....-...-");//
morseCodeSequence("..-..-...-....-...-----.---.--.-...-..-...-..-...-....-...-----.---.--.-...-..-.");//
morseCodeSequence(".-..---..-..---. ");//
morseCodeSequence(".--.--......-.-.-..--.-...--.--......-.-.-..--.-..");// -
delay(1000); // Wait for 1 second*
}
void morseCodeSequence(char* sequence)
{ -
int i = 0;*
-
// Loop for each element in the array*
_ while (sequence != NULL) _
_ {_
_ dotOrDash(sequence*); // Send out the dot or dash*
* i++; // Increment to the next element in the array*
* }
delay(dotDelay * 3); // gap between letters_
_}
void dotOrDash(char dotOrDash)
{
digitalWrite(ledPin, HIGH);
if (dotOrDash == '.')
{
delay(dotDelay);
}
else // must be a -
{
delay(dotDelay * 3);
}
digitalWrite(ledPin, LOW);
delay(dotDelay); // gap between flashes*
}_
we_were.ino (1.47 KB)