Please help for my project about the sketches combining

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);const int led = 13;
const int buz = 8;
String code = "";
int len = 0;
char ch;
char new_char;
int unit_delay = 250;

void dot()
{
Serial.print(".");
lcd.print(".");
digitalWrite(led, HIGH);
digitalWrite(buz, HIGH);
delay(unit_delay);
digitalWrite(led, LOW);
digitalWrite(buz, LOW);
delay(unit_delay);
}
void dash()
{
Serial.print("-");
lcd.print("-");
digitalWrite(led, HIGH);
digitalWrite(buz, HIGH);
delay(unit_delay * 3);
digitalWrite(led, LOW);
digitalWrite(buz, LOW);
delay(unit_delay);
}
void A()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void B()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void C()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void D()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void E()
{
dot();
delay(unit_delay);
}
void f()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void G()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void H()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void I()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void J()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void K()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void L()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void M()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void N()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void O()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void P()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
}
void Q()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void R()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void S()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void T()
{
dash();
delay(unit_delay);
}
void U()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void V()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void W()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void X()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void Y()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void Z()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void one()
{
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void two()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void three()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void four()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dash();
delay(unit_delay);
}
void five()
{
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void six()
{
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void seven()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void eight()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
dot();
delay(unit_delay);
}
void nine()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dot();
delay(unit_delay);
}
void zero()
{
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
dash();
delay(unit_delay);
}
void morse()
{
if (ch == 'A' || ch == 'a')
{
A();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'B' || ch == 'b')
{
B();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'C' || ch == 'c')
{
C();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'D' || ch == 'd')
{
D();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'E' || ch == 'e')
{
E();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'f' || ch == 'f')
{
f();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'G' || ch == 'g')
{
G();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'H' || ch == 'h')
{
H();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'I' || ch == 'i')
{
I();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'J' || ch == 'j')
{
J();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'K' || ch == 'k')
{
K();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'L' || ch == 'l')
{
L();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'M' || ch == 'm')
{
M();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'N' || ch == 'n')
{
N();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'O' || ch == 'o')
{
O();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'P' || ch == 'p')
{
P();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'Q' || ch == 'q')
{
Q();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'R' || ch == 'r')
{
R();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'S' || ch == 's')
{
S();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'T' || ch == 't')
{
T();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'U' || ch == 'u')
{
U();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'V' || ch == 'v')
{
V();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'W' || ch == 'w')
{
W();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'X' || ch == 'x')
{
X();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'Y' || ch == 'y')
{
Y();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == 'Z' || ch == 'z')
{
Z();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '0')
{
zero();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '1')
{
one();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '2')
{
two();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '3')
{
three();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '4')
{
four();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '5')
{
five();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '6')
{
six();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '7')
{
seven();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '8')
{
eight();
Serial.print(" ");
lcd.print(" ");
}
else if (ch == '9')
{
nine();
Serial.print(" ");
lcd.print(" ");
}
else if(ch == ' ')
{
delay(unit_delay*7);
Serial.print("/ ");
lcd.print(" ");
}
else
Serial.println("Unknown symbol!");
}
void String2Morse()
{
len = code.length();
for (int i = 0; i < len; i++)
{
ch = code.charAt(i);
morse();
}
}
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(buz, OUTPUT);
Serial.println("I am ready...");
// set up the LCD's number of columns and rows:
lcd.begin(16, 1);
// Print a message to the LCD.
lcd.print("Ready");

}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
while (Serial.available())
{
code = Serial.readString();
Serial.print(code);
Serial.print(" = ");
lcd.print(code);
lcd.print(" = ");
String2Morse();
Serial.println("");
lcd.print(" ");
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(1000);

}
delay(1000);

}
}

and

#include <LiquidCrystal.h> //to use LCD function download this library from arduino site
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);const int led = 13;
const int buz = 8;
String voice; //to store the command
char c; //to get characters from the command

void setup() {
Serial.begin(9600); //for serial terminal
lcd.begin(16,2); //initialize LCD
}

void loop() {
while(Serial.available())
{
delay(10); //delay added to make it stable
lcd.clear(); //clear LCD
c = Serial.read(); //get new command
voice += c; //to make a string of command
}
if(voice.length() > 0)
{
Serial.println(voice); //print the command in Serial Terminal
if(voice == "clear") //to clear the LCD send "clear" command
{
lcd.clear();
}
lcd.print(voice); //print the command on LCD
voice = ""; // to end the command
}
}

If i combine these sketches the bluetooth one doesnot work please help me for my project

It is really hard to help when the only description we have is "does not work". We need a good description of what you want the combined programs to do. Your code has not been posted with code tags so it is unformatted and hard to read. I suspect all the delays in the morse code program are causing a really big issue.

Waaaay too much code

both compile error-free under Uno AVR.

Concentrate on the loop() section, you are dealing with single characters in the Morse code (right) and dealing with "string" input on left pane. You can attack this several ways, but the easy way is to stay with the left methodology and use single-ASCII control characters to create new functionality in the Morse sketch.
For example 'clear display' could be converted to ASCII 127, the delete key.
image
Forum_1.ino (10.1 KB)

Second part
Forum_2.ino (944 Bytes)

When putting code on the forum, it should appear neat:

#include <LiquidCrystal.h> //to use LCD function download this library from arduino site
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); const int led = 13;
const int buz = 8;
String voice; //to store the command
char c; //to get characters from the command

void setup() {
  Serial.begin(9600); //for serial terminal
  lcd.begin(16, 2); //initialize LCD
}

void loop() {
  while (Serial.available())
  {
    delay(10); //delay added to make it stable
    lcd.clear(); //clear LCD
    c = Serial.read(); //get new command
    voice += c; //to make a string of command
  }
  if (voice.length() > 0)
  {
    Serial.println(voice); //print the command in Serial Terminal
    if (voice == "clear") //to clear the LCD send "clear" command
    {
      lcd.clear();
    }
    lcd.print(voice); //print the command on LCD
    voice = ""; // to end the command
  }
}


The Bluetooth side only works and it does not convert the character into morse code.

can you please combine it correctly for me i need to make it work within 1 day or otherwise i am gonna fail in my project

thanks bro it solved my problem

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.