Skip to main content
Tweeted twitter.com/#!/StackArduino/status/545598527678984193
tag; title; copyediting; formatting
Source Link
jfpoilpret
  • 9.1k
  • 7
  • 37
  • 54

I'm using the Arduino software to create a Morse code decoder using the serial monitor.

I enter a Morse code such as .- as a text string and itsit's displayed in the LCD as a alphanumeric text. So if iI enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.

Is there anywaya way to make the if statement as seen below accept both the dots and dashes together?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

I'm using the Arduino software to create a Morse code decoder using the serial monitor.

I enter a Morse code such as .- as a text string and its displayed in the LCD as a alphanumeric text. So if i enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.

Is there anyway to make the if statement as seen below accept both the dots and dashes together?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

I'm using the Arduino software to create a Morse code decoder using the serial monitor.

I enter a Morse code such as .- as a text string and it's displayed in the LCD as a alphanumeric text. So if I enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.

Is there a way to make the if statement as seen below accept both the dots and dashes together?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

arduino, Comparing a char with the symbols "'.-" within an if statement'

i'mI'm using the arduinoArduino software to create a morseMorse code decoder using the serial monitor.

so iI enter a morseMorse code such as ".-".- as a text string and its displayed in the lcdLCD as a alphanumeric text. soSo if i enter ".-".- into the serial Monitor, "A"A is displayed in lcd buton the LCD. But it only works for single symbols, not the dot and dash together.

isIs there anyway to make the if statement as seen below accept both the dots and dashes together as seen below?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

arduino, symbols ".-" within an if statement

i'm using the arduino software to create a morse code decoder using the serial monitor

so i enter a morse code such as ".-" as a text string and its displayed in the lcd as a alphanumeric text. so if i enter ".-" into the serial Monitor, "A" is displayed in lcd but it only works for single symbols not the dot and dash together

is there anyway to make the if statement accept both the dots and dashes together as seen below

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

Comparing a char with the symbols '.-'

I'm using the Arduino software to create a Morse code decoder using the serial monitor.

I enter a Morse code such as .- as a text string and its displayed in the LCD as a alphanumeric text. So if i enter .- into the serial Monitor, A is displayed on the LCD. But it only works for single symbols, not the dot and dash together.

Is there anyway to make the if statement as seen below accept both the dots and dashes together?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}
Formatted code sample
Source Link
BrettFolkins
  • 4.4k
  • 1
  • 14
  • 26

i'm using the arduino software to create a morse code decoder using the serial monitor

so i enter a morse code such as ".-" as a text string and its displayed in the lcd as a alphanumeric text. so if i enter ".-" into the serial Monitor, "A" is displayed in lcd but it only works for single symbols not the dot and dash together

is there anyway to make the if statement accept both the dots and dashes together as seen below

////

#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() { lcd.begin(16, 2);

Serial.begin(9600); }

void loop() { char schar;

if (Serial.available()) { schar = Serial.read();

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}

i'm using the arduino software to create a morse code decoder using the serial monitor

so i enter a morse code such as ".-" as a text string and its displayed in the lcd as a alphanumeric text. so if i enter ".-" into the serial Monitor, "A" is displayed in lcd but it only works for single symbols not the dot and dash together

is there anyway to make the if statement accept both the dots and dashes together as seen below

////

#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() { lcd.begin(16, 2);

Serial.begin(9600); }

void loop() { char schar;

if (Serial.available()) { schar = Serial.read();

Serial.write(schar);

if (schar== '.-' ){
Serial.write('A');
lcd.print('a');}}}

i'm using the arduino software to create a morse code decoder using the serial monitor

so i enter a morse code such as ".-" as a text string and its displayed in the lcd as a alphanumeric text. so if i enter ".-" into the serial Monitor, "A" is displayed in lcd but it only works for single symbols not the dot and dash together

is there anyway to make the if statement accept both the dots and dashes together as seen below

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16, 2);

 Serial.begin(9600);
}

void loop()
{
  char schar;

  if (Serial.available())
  {
    schar = Serial.read();

    Serial.write(schar);

    if (schar== '.-' ){
      Serial.write('A');
      lcd.print('a');
    }   
  }  
}
Source Link
Loading