hi
I am using this code
/*
MORSE ENDECODER
Morse encoder / decoder classes for the Arduino.
This example decodes Morse signals present on digital input 7.
(active low, and then also using the internal pullup resistor)
It also encodes Morse sent via the serial interface to the Arduino, on
digital output pin 13.
It can also decode audible signals, if using the constant MORSE_AUDIO
instead of MORSE_KEYER, but then it is important to note that the
input pin nr. will be for ANALOG inputs (0-5 on Atmega 168 - 328),
and not the digital inputs.
Copyright (C) 2010 raron
*/
#include <MorseEnDecoder.h>
int morseInPin = 4;
int morseOutPin = 6;
int x = 0;
int y = 0;
morseDecoder morseInput(morseInPin, MORSE_KEYER, MORSE_ACTIVE_LOW);
morseEncoder morseOutput(morseOutPin);
#include <LiquidCrystal.h> //include lcd library
LiquidCrystal lcd(11, 12, 7, 8, 9,10);
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
Serial.println("Morse EnDecoder demo");
// Setting Morse speed in wpm - words per minute
// If not set, 13 wpm is default
morseInput.setspeed(40);
morseOutput.setspeed(40);
}
void loop()
{
// Needs to call these once per loop
morseInput.decode();
morseOutput.encode();
// Morse output:
// Encoding text received from the serial input
if (Serial.available() && morseOutput.available())
{
char sendMorse = Serial.read();
morseOutput.write(sendMorse);
//String code=Serial.read();
if(x <=15){
// Also write it back to serial
morseOutput.encode(); // This is just to get morseSignalString before it is destroyed
Serial.write(' ');
Serial.write(sendMorse);
//Serial.write(morseOutput.morseSignalString);
lcd.setCursor(x,0);
lcd.print (sendMorse);
//lcd.setCursor(1,1);
//lcd.print(x);
x=x++;
}
if(x>=16){
char sendMorse = Serial.read();
morseOutput.write(sendMorse);
// Also write it back to serial
morseOutput.encode(); // This is just to get morseSignalString before it is destroyed
Serial.write(' ');
Serial.write(sendMorse);
//Serial.write(morseOutput.morseSignalString);
lcd.setCursor(y,1);
lcd.print (sendMorse);
//lcd.setCursor(0,0);
//lcd.print(y);
y=y++;
if((x>=16) && (y >=16)){
x=0;
y=0;
}
}
}
// Morse input:
// If a character is decoded from the input, write it to serial output
if (morseInput.available())
{
char receivedMorse = morseInput.read();
Serial.print(receivedMorse);
// A little error checking
if (receivedMorse == '#') Serial.println("< ERROR:too many morse signals! >");
}
// Morse feedback from input if not sending Morse.
if (morseOutput.available()) digitalWrite(morseOutPin, morseInput.morseSignalState);
}
the library it calls looks like this
#ifndef MorseEnDecoder_H
#define MorseEnDecoder_H
#if (ARDUINO < 100)
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
#define MORSE_AUDIO true
#define MORSE_KEYER false
#define MORSE_ACTIVE_LOW true
#define MORSE_ACTIVE_HIGH false
class morseDecoder
{
public:
morseDecoder(int decodePin, boolean listenAudio, boolean morsePullup);
void decode();
void setspeed(int value);
char read();
boolean available();
int AudioThreshold;
long debounceDelay; // the debounce time. Keep well below dotTime!!
boolean morseSignalState;
private:
int morseInPin; // The Morse input pin
int audioSignal;
int morseTableJumper;
int morseTablePointer;
int wpm; // Word-per-minute speed
long dotTime; // morse dot time length in ms
long dashTime;
long wordSpace;
boolean morseSpace; // Flag to prevent multiple received spaces
boolean gotLastSig; // Flag that the last received morse signal is decoded as dot or dash
boolean morseKeyer;
boolean lastKeyerState;
boolean morseAudio;
boolean activeLow;
long markTime; // timers for mark and space in morse signal
long spaceTime; // E=MC^2 ;p
long lastDebounceTime; // the last time the input pin was toggled
long currentTime; // The current (signed) time
char decodedMorseChar; // The last decoded Morse character
};
class morseEncoder
{
public:
morseEncoder(int encodePin);
void encode();
void setspeed(int value);
void write(char temp);
boolean available();
char morseSignalString[7];// Morse signal for one character as temporary ASCII string of dots and dashes
private:
char encodeMorseChar; // ASCII character to encode
int morseOutPin;
boolean sendingMorse;
int wpm; // Word-per-minute speed
long dotTime; // morse dot time length in ms
long dashTime;
long wordSpace;
int morseSignals; // nr of morse signals to send in one morse character
int morseSignalPos;
int sendingMorseSignalNr;
long sendMorseTimer;
long lastDebounceTime;
long currentTime;
};
#endif
in the guys demo of the code he has a buzzer and LED connected to the morse output , which buzz and light according to the morse code,
my buzzer doesnt have an internal tone generator,
I am hoping to use the tone() function
like this,
tone(6,4000);
to create a tone on the buzzer at the same time that the led lights, but i cant for the life of me find the part of code that lights the led,
i then assume that i would need a noTone(6) to stop it in the relevant place aswell, but im stumped,
any ideas?