Vai al contenuto
PLC Forum


decoder Cw con arduino nano


alexcanadair

Messaggi consigliati

Ciao a tutti finalmente è arrivata l'ora dopo parecchio tempo di costruire un decodificatore CW (codice Morse) con un arduino nano e un display 16X2 modello 1602A

abbiato con un microfono o un ingresso jack, volevo sapere se c'è gia un codice completo gia pronto all'uso e schema di collegamento per realizzarlo

deve avere questa funzione mano a mano che sente una nota cw deve tradurre in tempo reale e far comparire la traduzione in lettere e numeri e farlo scorrere man mano

io ad essere sincero sono gia partito con questo schema

decoder_bb_2.png

mettendo questo codice ma purtroppo non funziona compare solo i 16 rettangoli in basso ma non compare nessuna lettera

poi mi sono accorto che secondo la programmazione i pin del LCD non combaciavano con lo schema e ho fatto una inversione D7-2, D6-3, D5-4, D4-5, E-11, RS-12

e da li mi compariva finalmente qualcosa ovvero nella prima colonna del display in alto 00 WPM e nella seconda colonna durante la decodifica il led di arduino lampeggiva e compariva qualche lettera ma non la decodificava bene e quel poco che decodificava non comparivano le lettere a scorrimento ma blocchi di lettere casuali

mi potete aiutare ad affrontare questo problema? grazie in anticipo

///////////////////////////////////////////////////////////////////////
// CW Decoder made by Hjalmar Skovholm Hansen OZ1JHM  VER 1.01       //
// Feel free to change, copy or what ever you like but respect       //
// that license is http://www.gnu.org/copyleft/gpl.html //
// Discuss and give great ideas on                                   //
// https://groups.yahoo.com/neo/groups/oz1jhm/conversations/messages //
////////////////////////////////////////
///////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Read more here http://en.wikipedia.org/wiki/Goertzel_algorithm //
// if you want to know about FFT the http://www.dspguide.com/pdfbook.ht
m //
///////////////////////////////////////////////////////////////////////////
#include <LiquidCrystal.h>
///////////////////////////////////////////////
// select the pins used on the LCD panel      /
///////////////////////////////////////////////
//
LiquidCrystal lcd(RS, E, D4, D5, D6, D7) //
///////////////////////////////////////////////
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int colums = 20; /// have to be 16 or 20
const int rows = 4;  /// have to be 2 or 4
int lcdindex = 0;
int line1[co
lums];
int line2[colums];
////////////////////////////////
// Define 8 specials letters  //
////////////////////////////////
byte U_umlaut[8] =   {B01010,B00000,B10001,B10001,B10001,B10001,B01110,B00000}; //
'Ü'  
byte O_umlaut[8] =   
{B01010,B00000,B01110,B10001,B10001,B10001,B01110,B00000}; //
'Ö'  
byte A_umlaut[8] =   {B01010,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; //
'Ä'    
byte AE_capital[8] = {B01111,B10100,B10100,B11110,B10100,B10100,B10111,B00000}; //
'Æ'
byte OE_c
apital[8] = {B00001,B01110,B10011,B10101,B11001,B01110,B10000,B00000}; //
'Ø'
byte fullblock[8] =  {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};  
byte AA_capital[8] = {B00100,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; //
'Å'   
byte
emtyblock[8] =  {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B00000};  
int audioInPin = A1;
int audioOutPin = 10;
int ledPin = 13;
float magnitude ;
int magnitudelimit = 100;
int magnitudelimit_low = 100;
int realstate = LOW;
int realstatebefore =
LOW;
int filteredstate = LOW;
int filteredstatebefore = LOW;
///////////////////////////////////////////////////////////
// The sampling frq will be 8928 on a 16 mhz             //
// without any prescaler etc                             //
// because we need the tone in the center of the bins    //
// you can set the tone to 496, 558, 744 or 992          //
// then n the number of samples which give the bandwidth //
// can be (8928 / tone) * 1 or 2 or 3 or 4 etc           //
// init is 8928/
558 = 16 *4 = 64 samples                 //
// try to take n = 96 or 128 ;o)                         //
// 48 will give you a bandwidth around 186 hz            //
// 64 will give you a bandwidth around 140 hz            //
// 96 will give you a bandwidth
around 94 hz             //
// 128 will give you a bandwidth around 70 hz            //
// BUT remember that high n take a lot of time           //
// so you have to find the compromice
-
i use 48         //
////////////////////////////////////////////////
///////////
float coeff;
float Q1 = 0;
float Q2 = 0;
float sine;
float cosine;  
float sampling_freq=8928.0;
float target_freq=558.0; /// adjust for your needs see above
float n=48.0;  //// if you change  her please change next line also
int testData[48]
;
//////////////////////////////
// Noise Blanker time which //
// shall be computed so     //
// this is initial          //
//////////////////////////////
int nbtime = 6;  /// ms noise blanker         
long starttimehigh;
long highduration;
long lasthighduration;
long hightimesavg;
long lowtimesavg;
long startttimelow;
long lowduration;
long laststarttime = 0;
char code[20];
int stop = LOW;
int wpm;
////////////////
// init setup //
////////////////
void setup() {
////////////////////////
////////////
// The basic goertzel calculation //
////////////////////////////////////
int
k;
float
omega;
k = (int) (0.5 + ((n * target_freq) / sampling_freq));
omega = (2.0 * PI * k) / n;
sine = sin(omega);
cosine = cos(omega);
coeff = 2.0 * cosine;
///////////////////////////////
// define special characters //
///////////////////////////////
lcd.createChar(0, U_umlaut); //     German
lcd.createChar(1, O_umlaut); //     German, Swedish
lcd.createChar(2, A_umlaut); //     Ger
man, Swedish
lcd.createChar(3, AE_capital); //   Danish, Norwegian
lcd.createChar(4, OE_capital); //   Danish, Norwegian
lcd.createChar(5, fullblock);        
lcd.createChar(6, AA_capital); //   Danish, Norwegian, Swedish
lcd.createChar(7, emtyblock)
;
lcd.clear();
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
lcd.begin(colums, rows);
for (int index = 0; index < colums; index++){
line1[index] = 32;
line2[index] = 32;
}           
}
///////////////
// main loop //
///////////////
void loop() {
/////////////////////////////////////
// The basic where we get the tone //
/////////////////////////////////////
for (char index = 0; index < n; index++)
{
testData[index] = analogRead(audioInPin);
}
for (char index =
0; index < n; index++){
float Q0;
Q0 = coeff * Q1
-
Q2 + (float) testData[index];
Q2 = Q1;
Q1 = Q0;
}
float magnitudeSquared = (Q1*Q1)+(Q2*Q2)
-
Q1*Q2*coeff;  // we do only need the real
part //
magnitude = sqrt(magnitudeSquared);
Q2 = 0
;
Q1 = 0;
//Serial.print(magnitude); Serial.println();  //// here you can measure magnitude
for setup..
///////////////////////////////////////////////////////////
// here we will try to set the magnitude limit automatic //
/////////////////
//////////////////////////////////////////
if (magnitude > magnitudelimit_low){
magnitudelimit = (magnitudelimit +((magnitude
-
magnitudelimit)/6));  /// moving
average filter
}
if (magnitudelimit < magnitudelimit_low)
magnitudelimit = magnitudelimit_low;
////////////////////////////////////
// now we check for the magnitude //
////////////////////////////////////
if(magnitude > magnitudelimit*0.6) // just to have some space up
realstate = HIGH;
else
realstate = LOW;
/////////////////////////////////////////////////////
// here we clean up the state with a noise blanker //
/////////////////////////////////////////////////////
if (realstate != realstatebefore){
laststarttime = milli
s();
}
if ((millis()
-
laststarttime)> nbtime){
if (realstate != filteredstate){
filteredstate = realstate;
}
}
////////////////////////////////////////////////////////////
// Then we do want to have some durations on high and low //
////////////////////////////////////////////////////////////
if (filteredstate != filteredstatebefore){
if (filteredstate == HIGH){
starttimehigh = millis();
lowduration = (millis()
-
startttimelow);
}
if (filteredstate == LOW){
startttimelow
= millis();
highduration = (millis()
-
starttimehigh);
if (highduration < (2*hightimesavg) || hightimesavg == 0){
hightimesavg = (highduration+hightimesavg+hightimesavg)/3;     
// now we know avg dit time ( rolling 3 avg)
}
if (highduratio
n > (5*hightimesavg) ){
hightimesavg = highduration+hightimesavg;     // if speed
decrease fast ..
}
}
}
///////////////////////////////////////////////////////////////
// now we will check which kind of baud we have
-
dit or dah //
// and what
kind of pause we do have 1
-
3 or 7 pause        //
// we think that hightimeavg = 1 bit                         //
///////////////////////////////////////////////////////////////
if (filteredstate != filteredstatebefore){
stop = LOW;
if (filtere
dstate == LOW){  //// we did end a HIGH
if (highduration < (hightimesavg*2) && highduration > (hightimesavg*0.6)){ /// 0.6
filter out false dits
strcat(code,".");
Serial.print(".");
}
if (highduration > (hightimesavg*2) && highduration < (high
timesavg*6)){
strcat(code,"
-
");
Serial.print("
-
");
wpm = (wpm + (1200/((highduration)/3)))/2;  //// the most precise we can do
;o)
}
}
if (filteredstate == HIGH){  //// we did end a LOW
float lacktime = 1;
if(wpm > 25)lacktime=1.0;
///  when high speeds we have to have a little more
pause before new letter or new word
if(wpm > 30)lacktime=1.2;
if(wpm > 35)lacktime=1.5;
if (lowduration > (hightimesavg*(2*lacktime)) && lowduration <
hightimesavg*(5*lacktime)){ // letter s
pace
docode();
code[0] = '
\
0';
Serial.print("/");
}
if (lowduration >= hightimesavg*(5*lacktime)){ // word space
docode();
code[0] = '
\
0';
printascii(32);
Serial.println();
}
}
}
//////////////////////////////
// write if no more letters //
//////////////////////////////
if ((millis()
-
startttimelow) > (highduration * 6) && stop == LOW){
docode();
code[0] = '
\
0';
stop = HIGH;
}
/////////////////////////////////////
// we will turn on and off t
he LED //
// and the speaker                 //
/////////////////////////////////////
if(filteredstate == HIGH){
digitalWrite(ledPin, HIGH);
tone(audioOutPin,target_freq);
}
else{
digitalWrite(ledPin, LOW);
noTone(audioOutPin);
}
//////////////////////////////////
// the end of main loop clean up//
/////////////////////////////////
updateinfolinelcd();
realstatebefore = realstate;
lasthighduration = highduration;
filteredstatebefore = filteredstate;
}
////////////////////////////////
// translate cw code to ascii //
////////////////////////////////
void docode(){
if (strcmp(code,".
-
") == 0) printascii(65);
if (strcmp(code,"
-
...") == 0) printascii(66);
if (strcmp(code,"
-
.
-
.") == 0) printascii(67);
if (strcmp(code,"
-
..") == 0) printascii(68);
if (strcmp(code,".") == 0) printascii(69);
if (strcmp(code,"..
-
.") == 0) printascii(70);
if (strcmp(code,"
--
.") == 0) printascii(71);
if (strcmp(code,"....") == 0) printascii(72);
if (strcmp(code,"..") ==
0) printascii(73);
if (strcmp(code,".
---
") == 0) printascii(74);
if (strcmp(code,"
-
.
-
") == 0) printascii(75);
if (strcmp(code,".
-
..") == 0) printascii(76);
if (strcmp(code,"
--
") == 0) printascii(77);
if (strcmp(code,"
-
.") == 0) printascii(78);
if (s
trcmp(code,"
---
") == 0) printascii(79);
if (strcmp(code,".
--
.") == 0) printascii(80);
if (strcmp(code,"
--
.
-
") == 0) printascii(81);
if (strcmp(code,".
-
.") == 0) printascii(82);
if (strcmp(code,"...") == 0) printascii(83);
if (strcmp(code,"
-
") == 0) printascii(84);
if (strcmp(code,"..
-
") == 0) printascii(85);
if (strcmp(code,"...
-
") == 0) printascii(86);
if (strcmp(code,".
--
") == 0) printascii(87);
if (strcmp(code,"
-
..
-
") == 0) printascii(88);
if (strcmp(code,"
-
.
--
") ==
0) printascii(89);
if (strcmp(code,"
--
..") == 0) printascii(90);
if (strcmp(code,".
----
") == 0) printascii(49);
if (strcmp(code,"..
---
") == 0) printascii(50);
if (strcmp(code,"...
--
") == 0) printascii(51);
if (strcmp(code,"....
-
") == 0) printascii(5
2);
if (strcmp(code,".....") == 0) printascii(53);
if (strcmp(code,"
-
....") == 0) printascii(54);
if (strcmp(code,"
--
...") == 0) printascii(55);
if (strcmp(code,"
---
..") == 0) printascii(56);
if (strcmp(code,"
----
.") == 0) printascii(57);
if (strcmp(
code,"
-----
") == 0) printascii(48);
if (strcmp(code,"..
--
..") == 0) printascii(63);
if (strcmp(code,".
-
.
-
.
-
") == 0) printascii(46);
if (strcmp(code,"
--
..
--
") == 0) printascii(44);
if (strcmp(code,"
-
.
-
.
--
") == 0) printascii(33);
if (strcmp(code,".
--
.
-
.") == 0) printascii(64);
if (strcmp(code,"
---
...") == 0) printascii(58);
if (strcmp(code,"
-
....
-
") == 0) printascii(45);
if (strcmp(code,"
-
..
-
.") == 0) printascii(47);
if (strcmp(code,"
-
.
--
.") == 0) printascii(40);
if (strcmp(code,"
-
.
--
.
-
") == 0) printascii(41);
if (strcmp(code,".
-
...") == 0) printascii(95);
if (strcmp(code,"...
-
..
-
") == 0) printascii(36);
if (strcmp(code,"...
-
.
-
") == 0) printascii(62);
if (strcmp(code,".
-
.
-
.") == 0) printascii(60);
if (strcmp(c
ode,"...
-
.")
== 0) printascii(126);
//////////////////
// The specials //
//////////////////
if (strcmp(code,".
-
.
-
")
== 0) printascii(3);
if (strcmp(code,"
---
.") == 0) printascii(4);
if (strcmp(code,".
--
.
-
) == 0) printascii(6);
}
/////////////////
////////////////////
// print the ascii code to the lcd //
// one a time so we can generate   //
// special letters                 //
/////////////////////////////////////
void printascii(int asciinumber){
int fail = 0;
if (rows == 4 and colums == 16)fai
l =
-
4; /// to fix the library problem with 4*16
display http://forum.arduino.cc/index.php/topic,14604.0.html
if (lcdindex > colums
-
1){
lcdindex = 0;
if (rows==4){
for (int i = 0; i <= colums
-
1 ; i++){
lcd.setCursor(i,rows
-
3);
lcd.write(line2);
line2=line1;
}
}
for (int i = 0; i <= colums
-
1 ; i++){
lcd.setCursor(i+fail,rows
-
2);
lcd.write(line1);
lcd.setCursor(i+fail,rows
-
1);
lcd.write(32);
}
}
line1[lcdindex]=asciinumber;
lcd.setCursor(lcd
index+fail,rows
-
1);
lcd.write(asciinumber);
lcdindex += 1;
}
void updateinfolinelcd(){
/////////////////////////////////////
// here we update the upper line   //
// with the speed.                 //
/////////////////////////////////////
int place;
if (rows == 4){
place = colums/2;}
else{
place = 2;
}
if (wpm<10){
lcd.setCursor((place)
-
2,0);
lcd.print("0");
lcd.setCursor((place)
-
1,0);
lcd.print(wpm);
lcd.setCursor((place),0);
lcd.print(" WPM");
}
else{
lcd.setCursor((place)
-
2,0);
lcd.print(wpm);
lcd.setCursor((place),0);
lcd.print(" WPM ");
}
}

Link al commento
Condividi su altri siti


Ma quello non è il nano.

 

Usa l'algoritmo di Goertzel per rilevare il tono.

Quote

you can set the tone to 496, 558, 744 or 992 

 La banda passante è determinata dal valore di n

Quindi se il tono non rientra nella banda passante del filtro, non decodifica nulla

Quote

/ try to take n = 96 or 128 ;o)                         //
// 48 will give you a bandwidth around 186 hz            //
// 64 will give you a bandwidth around 140 hz            //
// 96 will give you a bandwidth
around 94 hz             //
// 128 will give you a bandwidth around 70 hz            //
// BUT remember that high n take a lot of time           //
// so you have to find the compromice

Inoltre captare il tono con un microfono non mi sembra un'idea brillante. 

Meglio entrare prelevando il segnale magari dall'uscita rec della radio.

 

Ma non trovi un codice migliore?

Link al commento
Condividi su altri siti

Buon pomeriggio Cicala :)

hai perfettamente ragione, come infatti ci stavo lavorando, e sono riuscito a fare un ottimo collegamento e programmazione trovando un altro codice

però provvisoriamente sempre con il microfono solo per fare un test, adesso decodifica perfettamente ma solo ad una determinata banda passate ( tono)

a questio punto metto una presa jack da 3,5mm con interruttore integrato che esclude il microfono e funziona come hai detto te con un cavo out o rec che va alla radio, ti elenco il codice attuale inserito su arduino nano, però vorrei fare due modifiche se è possibile, 1) vorrei mettere un interruttore per modificare la banda passante del tono da decodificare,

2) vorrei che questo decoder CW ad ogni accensione mi compare per 2-3 secondi un breve messaggio fisso con scritto solo il mio nominativo e poi va allo stato di decodifica, cosa devo modificare in questa stringa di codici?

///////////////////////////////////////////////////////////////////////
// CW Decoder made by Hjalmar Skovholm Hansen OZ1JHM  VER 1.01       //
// Feel free to change, copy or what ever you like but respect       //
// that license is http://www.gnu.org/copyleft/gpl.html //
// Discuss and give great ideas on                                   //
// https://groups.yahoo.com/neo/groups/oz1jhm/conversations/messages //
///////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
// Read more here http://en.wikipedia.org/wiki/Goertzel_algorithm //
// if you want to know about FFT the http://www.dspguide.com/pdfbook.htm //
///////////////////////////////////////////////////////////////////////////

#include <LiquidCrystal.h>

///////////////////////////////////////////////
// select the pins used on the LCD panel      /
///////////////////////////////////////////////
//  LiquidCrystal lcd(RS, E, D4, D5, D6, D7) //
///////////////////////////////////////////////

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int colums = 16; /// have to be 16 or 20
const int rows = 2;  /// have to be 2 or 4

int lcdindex = 0;
int line1[colums];
int line2[colums];

////////////////////////////////
// Define 8 specials letters  //
////////////////////////////////

byte U_umlaut[8] =   {B01010,B00000,B10001,B10001,B10001,B10001,B01110,B00000}; // 'Ü'  
byte O_umlaut[8] =   {B01010,B00000,B01110,B10001,B10001,B10001,B01110,B00000}; // 'Ö'  
byte A_umlaut[8] =   {B01010,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Ä'    
byte AE_capital[8] = {B01111,B10100,B10100,B11110,B10100,B10100,B10111,B00000}; // 'Æ'
byte OE_capital[8] = {B00001,B01110,B10011,B10101,B11001,B01110,B10000,B00000}; // 'Ø'
byte fullblock[8] =  {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};  
byte AA_capital[8] = {B00100,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Å'   
byte emtyblock[8] =  {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B00000};  

int audioInPin = A1;
int audioOutPin = 10;
int ledPin = 13;

float magnitude ;
int magnitudelimit = 100;
int magnitudelimit_low = 100;
int realstate = LOW;
int realstatebefore = LOW;
int filteredstate = LOW;
int filteredstatebefore = LOW;


///////////////////////////////////////////////////////////
// The sampling frq will be 8928 on a 16 mhz             //
// without any prescaler etc                             //
// because we need the tone in the center of the bins    //
// you can set the tone to 496, 558, 744 or 992          //
// then n the number of samples which give the bandwidth //
// can be (8928 / tone) * 1 or 2 or 3 or 4 etc           //
// init is 8928/558 = 16 *4 = 64 samples                 //
// try to take n = 96 or 128 ;o)                         //
// 48 will give you a bandwidth around 186 hz            //
// 64 will give you a bandwidth around 140 hz            //
// 96 will give you a bandwidth around 94 hz             //
// 128 will give you a bandwidth around 70 hz            //
// BUT remember that high n take a lot of time           //
// so you have to find the compromice - i use 48         //
///////////////////////////////////////////////////////////

float coeff;
float Q1 = 0;
float Q2 = 0;
float sine;
float cosine;  
float sampling_freq=8928.0;
float target_freq=558.0; /// adjust for your needs see above
float n=48.0;  //// if you change  her please change next line also
int testData[48];

//////////////////////////////
// Noise Blanker time which //
// shall be computed so     //
// this is initial          //
//////////////////////////////
int nbtime = 6;  /// ms noise blanker         

long starttimehigh;
long highduration;
long lasthighduration;
long hightimesavg;
long lowtimesavg;
long startttimelow;
long lowduration;
long laststarttime = 0;

char code[20];
int stop = LOW;
int wpm;


////////////////
// init setup //
////////////////
void setup() {

////////////////////////////////////
// The basic goertzel calculation //
////////////////////////////////////
  int  k;
  float omega;
  k = (int) (0.5 + ((n * target_freq) / sampling_freq));
  omega = (2.0 * PI * k) / n;
  sine = sin(omega);
  cosine = cos(omega);
  coeff = 2.0 * cosine;

///////////////////////////////
// define special characters //
///////////////////////////////
 lcd.createChar(0, U_umlaut); //     German
 lcd.createChar(1, O_umlaut); //     German, Swedish
 lcd.createChar(2, A_umlaut); //     German, Swedish
 lcd.createChar(3, AE_capital); //   Danish, Norwegian
 lcd.createChar(4, OE_capital); //   Danish, Norwegian
 lcd.createChar(5, fullblock);        
 lcd.createChar(6, AA_capital); //   Danish, Norwegian, Swedish
 lcd.createChar(7, emtyblock);
 lcd.clear();

 Serial.begin(115200);
 pinMode(ledPin, OUTPUT);
 lcd.begin(colums, rows);
 for (int index = 0; index < colums; index++){
    line1[index] = 32;
  line2[index] = 32;
 }           
 
}

///////////////
// main loop //
///////////////
 void loop() {

  /////////////////////////////////////
  // The basic where we get the tone //
  /////////////////////////////////////
 
  for (char index = 0; index < n; index++)
  {
    testData[index] = analogRead(audioInPin);
  }
  for (char index = 0; index < n; index++){
    float Q0;
    Q0 = coeff * Q1 - Q2 + (float) testData[index];
    Q2 = Q1;
    Q1 = Q0;  
  }
  float magnitudeSquared = (Q1*Q1)+(Q2*Q2)-Q1*Q2*coeff;  // we do only need the real part //
  magnitude = sqrt(magnitudeSquared);
  Q2 = 0;
  Q1 = 0;

  //Serial.print(magnitude); Serial.println();  //// here you can measure magnitude for setup..
 
  ///////////////////////////////////////////////////////////
  // here we will try to set the magnitude limit automatic //
  ///////////////////////////////////////////////////////////
 
  if (magnitude > magnitudelimit_low){
    magnitudelimit = (magnitudelimit +((magnitude - magnitudelimit)/6));  /// moving average filter
  }
 
  if (magnitudelimit < magnitudelimit_low)
  magnitudelimit = magnitudelimit_low;
 
  ////////////////////////////////////
  // now we check for the magnitude //
  ////////////////////////////////////

  if(magnitude > magnitudelimit*0.6) // just to have some space up
     realstate = HIGH;
  else
    realstate = LOW;
 
  /////////////////////////////////////////////////////
  // here we clean up the state with a noise blanker //
  /////////////////////////////////////////////////////
 
  if (realstate != realstatebefore){
  laststarttime = millis();
  }
  if ((millis()-laststarttime)> nbtime){
  if (realstate != filteredstate){
    filteredstate = realstate;
  }
  }
 
 ////////////////////////////////////////////////////////////
 // Then we do want to have some durations on high and low //
 ////////////////////////////////////////////////////////////
 
 if (filteredstate != filteredstatebefore){
  if (filteredstate == HIGH){
    starttimehigh = millis();
    lowduration = (millis() - startttimelow);
  }

  if (filteredstate == LOW){
    startttimelow = millis();
    highduration = (millis() - starttimehigh);
        if (highduration < (2*hightimesavg) || hightimesavg == 0){
      hightimesavg = (highduration+hightimesavg+hightimesavg)/3;     // now we know avg dit time ( rolling 3 avg)
    }
    if (highduration > (5*hightimesavg) ){
      hightimesavg = highduration+hightimesavg;     // if speed decrease fast ..
    }
  }
  }

 ///////////////////////////////////////////////////////////////
 // now we will check which kind of baud we have - dit or dah //
 // and what kind of pause we do have 1 - 3 or 7 pause        //
 // we think that hightimeavg = 1 bit                         //
 ///////////////////////////////////////////////////////////////
 
 if (filteredstate != filteredstatebefore){
  stop = LOW;
  if (filteredstate == LOW){  //// we did end a HIGH
   if (highduration < (hightimesavg*2) && highduration > (hightimesavg*0.6)){ /// 0.6 filter out false dits
  strcat(code,".");
  Serial.print(".");
   }
   if (highduration > (hightimesavg*2) && highduration < (hightimesavg*6)){
  strcat(code,"-");
  Serial.print("-");
  wpm = (wpm + (1200/((highduration)/3)))/2;  //// the most precise we can do ;o)
   }
  }
 
   if (filteredstate == HIGH){  //// we did end a LOW
   
   float lacktime = 1;
   if(wpm > 25)lacktime=1.0; ///  when high speeds we have to have a little more pause before new letter or new word
   if(wpm > 30)lacktime=1.2;
   if(wpm > 35)lacktime=1.5;
   
   if (lowduration > (hightimesavg*(2*lacktime)) && lowduration < hightimesavg*(5*lacktime)){ // letter space
    docode();
  code[0] = '\0';
  Serial.print("/");
   }
   if (lowduration >= hightimesavg*(5*lacktime)){ // word space
    docode();
  code[0] = '\0';
  printascii(32);
  Serial.println();
   }
  }
 }
 
 //////////////////////////////
 // write if no more letters //
 //////////////////////////////

  if ((millis() - startttimelow) > (highduration * 6) && stop == LOW){
   docode();
   code[0] = '\0';
   stop = HIGH;
  }

 /////////////////////////////////////
 // we will turn on and off the LED //
 // and the speaker                 //
 /////////////////////////////////////
 
   if(filteredstate == HIGH){
     digitalWrite(ledPin, HIGH);
   tone(audioOutPin,target_freq);
   }
   else{
     digitalWrite(ledPin, LOW);
   noTone(audioOutPin);
   }
 
 //////////////////////////////////
 // the end of main loop clean up//
 /////////////////////////////////
 updateinfolinelcd();
 realstatebefore = realstate;
 lasthighduration = highduration;
 filteredstatebefore = filteredstate;
 }


////////////////////////////////
// translate cw code to ascii //
////////////////////////////////

void docode(){
    if (strcmp(code,".-") == 0) printascii(65);
  if (strcmp(code,"-...") == 0) printascii(66);
  if (strcmp(code,"-.-.") == 0) printascii(67);
  if (strcmp(code,"-..") == 0) printascii(68);
  if (strcmp(code,".") == 0) printascii(69);
  if (strcmp(code,"..-.") == 0) printascii(70);
  if (strcmp(code,"--.") == 0) printascii(71);
  if (strcmp(code,"....") == 0) printascii(72);
  if (strcmp(code,"..") == 0) printascii(73);
  if (strcmp(code,".---") == 0) printascii(74);
  if (strcmp(code,"-.-") == 0) printascii(75);
  if (strcmp(code,".-..") == 0) printascii(76);
  if (strcmp(code,"--") == 0) printascii(77);
  if (strcmp(code,"-.") == 0) printascii(78);
  if (strcmp(code,"---") == 0) printascii(79);
  if (strcmp(code,".--.") == 0) printascii(80);
  if (strcmp(code,"--.-") == 0) printascii(81);
  if (strcmp(code,".-.") == 0) printascii(82);
  if (strcmp(code,"...") == 0) printascii(83);
  if (strcmp(code,"-") == 0) printascii(84);
  if (strcmp(code,"..-") == 0) printascii(85);
  if (strcmp(code,"...-") == 0) printascii(86);
  if (strcmp(code,".--") == 0) printascii(87);
  if (strcmp(code,"-..-") == 0) printascii(88);
  if (strcmp(code,"-.--") == 0) printascii(89);
  if (strcmp(code,"--..") == 0) printascii(90);

  if (strcmp(code,".----") == 0) printascii(49);
  if (strcmp(code,"..---") == 0) printascii(50);
  if (strcmp(code,"...--") == 0) printascii(51);
  if (strcmp(code,"....-") == 0) printascii(52);
  if (strcmp(code,".....") == 0) printascii(53);
  if (strcmp(code,"-....") == 0) printascii(54);
  if (strcmp(code,"--...") == 0) printascii(55);
  if (strcmp(code,"---..") == 0) printascii(56);
  if (strcmp(code,"----.") == 0) printascii(57);
  if (strcmp(code,"-----") == 0) printascii(48);

  if (strcmp(code,"..--..") == 0) printascii(63);
  if (strcmp(code,".-.-.-") == 0) printascii(46);
  if (strcmp(code,"--..--") == 0) printascii(44);
  if (strcmp(code,"-.-.--") == 0) printascii(33);
  if (strcmp(code,".--.-.") == 0) printascii(64);
  if (strcmp(code,"---...") == 0) printascii(58);
  if (strcmp(code,"-....-") == 0) printascii(45);
  if (strcmp(code,"-..-.") == 0) printascii(47);

  if (strcmp(code,"-.--.") == 0) printascii(40);
  if (strcmp(code,"-.--.-") == 0) printascii(41);
  if (strcmp(code,".-...") == 0) printascii(95);
  if (strcmp(code,"...-..-") == 0) printascii(36);
  if (strcmp(code,"...-.-") == 0) printascii(62);
  if (strcmp(code,".-.-.") == 0) printascii(60);
  if (strcmp(code,"...-.") == 0) printascii(126);
  //////////////////
  // The specials //
  //////////////////
  if (strcmp(code,".-.-") == 0) printascii(3);
  if (strcmp(code,"---.") == 0) printascii(4);
  if (strcmp(code,".--.-") == 0) printascii(6);

}

/////////////////////////////////////
// print the ascii code to the lcd //
// one a time so we can generate   //
// special letters                 //
/////////////////////////////////////
void printascii(int asciinumber){

int fail = 0;
if (rows == 4 and colums == 16)fail = -4; /// to fix the library problem with 4*16 display http://forum.arduino.cc/index.php/topic,14604.0.html
 
 if (lcdindex > colums-1){
  lcdindex = 0;
  if (rows==4){
    for (int i = 0; i <= colums-1 ; i++){
    lcd.setCursor(i,rows-3);
    lcd.write(line2);
    line2=line1;
    }
   }
  for (int i = 0; i <= colums-1 ; i++){
    lcd.setCursor(i+fail,rows-2);
    lcd.write(line1);
  lcd.setCursor(i+fail,rows-1);
    lcd.write(32);
  }
 }
 line1[lcdindex]=asciinumber;
 lcd.setCursor(lcdindex+fail,rows-1);
 lcd.write(asciinumber);
 lcdindex += 1;
}

void updateinfolinelcd(){
/////////////////////////////////////
// here we update the upper line   //
// with the speed.                 //
/////////////////////////////////////

  int place;
  if (rows == 4){
   place = colums/2;}
  else{
   place = 2;
  }
  if (wpm<10){
    lcd.setCursor((place)-2,0);
    lcd.print("0");
    lcd.setCursor((place)-1,0);
    lcd.print(wpm);
    lcd.setCursor((place),0);
    lcd.print(" BPM ");
  }
  else{
    lcd.setCursor((place)-2,0);
    lcd.print(wpm);
    lcd.setCursor((place),0);
    lcd.print(" BPM ");
  }

}

Link al commento
Condividi su altri siti

Quando inserisci file dicodice usa il tasto "code", quello con l'icona "<>", altrimenti il messaggio risulta poco comprensibile.

Link al commento
Condividi su altri siti

Si davvero....fa schioppare gli occhi :superlol:

 

byte U_umlaut[8] =   {B01010,B00000,B10001,B10001,B10001,B10001,B01110,B00000}; // 'Ü'  
byte O_umlaut[8] =   {B01010,B00000,B01110,B10001,B10001,B10001,B01110,B00000}; // 'Ö'  
byte A_umlaut[8] =   {B01010,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Ä'    
byte AE_capital[8] = {B01111,B10100,B10100,B11110,B10100,B10100,B10111,B00000}; // 'Æ'
byte OE_capital[8] = {B00001,B01110,B10011,B10101,B11001,B01110,B10000,B00000}; // 'Ø'
byte AA_capital[8] = {B00100,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Å'  

 

Ma che te ne fai di questi caratteri?

 

Io nel mio non li ho proprio considerati; l'hai visto?

http://www.plcforum.it/f/topic/205230-che-cos-è-questo/?page=1

 

Per quanto concerne l'inserimento del messaggio....aspettiamo il consiglio degli arduinisti

 

 

Link al commento
Condividi su altri siti

bhe, io ho trovato gia una programmazione pronta ho dovuto solo modificare il tipo di lcd

e di mettere la stringa per un display 16X2

due colonne per il resto non ho toccato nulla :lol:

Link al commento
Condividi su altri siti

comunque ho provato a cercare in giro per mettere il messaggio di avvio per un tot di secondi, e sopratutto la variazione della banda passante, ma non ho trovato nulla di interessante? :(

Link al commento
Condividi su altri siti

...prova ad innestare questo

 ///////////////
 // message   //
 /////////////// 
   void message() { 
    lcd.print("testo, testo");
	delay(1000);
  } 

 ///////////////
 // main loop //
 ///////////////
  void loop() { 

	message();

 

Link al commento
Condividi su altri siti

Se il messaggio deve essere iniziale metti il richiamo non nel loop ma alla fine del setup.

la funzione messaggio la scrivi alla fine di tutto

 

void setup() {

////////////////////////////////////
// The basic goertzel calculation //
////////////////////////////////////
  int  k;
  float omega;
  k = (int) (0.5 + ((n * target_freq) / sampling_freq));
  omega = (2.0 * PI * k) / n;
  sine = sin(omega);
  cosine = cos(omega);
  coeff = 2.0 * cosine;
------------
 for (int index = 0; index < colums; index++){
    line1[index] = 32;
  line2[index] = 32;
  message();                                  
 }        

 

Link al commento
Condividi su altri siti

chiedo scusa ma non capisco mi potete copiare e incollare il codice con questa funzione? ci ho provato ma non me lo fa caricare

al 100% sto sbagliando io

Link al commento
Condividi su altri siti

///////////////////////////////////////////////////////////////////////
// CW Decoder made by Hjalmar Skovholm Hansen OZ1JHM  VER 1.01       //
// Feel free to change, copy or what ever you like but respect       //
// that license is http://www.gnu.org/copyleft/gpl.html //
// Discuss and give great ideas on                                   //
// https://groups.yahoo.com/neo/groups/oz1jhm/conversations/messages //
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Read more here http://en.wikipedia.org/wiki/Goertzel_algorithm //
// if you want to know about FFT the http://www.dspguide.com/pdfbook.htm //
///////////////////////////////////////////////////////////////////////////
#include <LiquidCrystal.h>
///////////////////////////////////////////////
// select the pins used on the LCD panel      /
///////////////////////////////////////////////
//  LiquidCrystal lcd(RS, E, D4, D5, D6, D7) //
///////////////////////////////////////////////
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int colums = 16; /// have to be 16 or 20
const int rows = 2;  /// have to be 2 or 4
int lcdindex = 0;
int line1[colums];
int line2[colums];
////////////////////////////////
// Define 8 specials letters  //
////////////////////////////////
byte U_umlaut[8] =   {B01010,B00000,B10001,B10001,B10001,B10001,B01110,B00000}; // 'Ü'  
byte O_umlaut[8] =   {B01010,B00000,B01110,B10001,B10001,B10001,B01110,B00000}; // 'Ö'  
byte A_umlaut[8] =   {B01010,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Ä'    
byte AE_capital[8] = {B01111,B10100,B10100,B11110,B10100,B10100,B10111,B00000}; // 'Æ'
byte OE_capital[8] = {B00001,B01110,B10011,B10101,B11001,B01110,B10000,B00000}; // 'Ø'
byte fullblock[8] =  {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};  
byte AA_capital[8] = {B00100,B00000,B01110,B10001,B11111,B10001,B10001,B00000}; // 'Ã…'   
byte emtyblock[8] =  {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B00000};  
int audioInPin = A1;
int audioOutPin = 10;
int ledPin = 13;
float magnitude ;
int magnitudelimit = 100;
int magnitudelimit_low = 100;
int realstate = LOW;
int realstatebefore = LOW;
int filteredstate = LOW;
int filteredstatebefore = LOW;

///////////////////////////////////////////////////////////
// The sampling frq will be 8928 on a 16 mhz             //
// without any prescaler etc                             //
// because we need the tone in the center of the bins    //
// you can set the tone to 496, 558, 744 or 992          //
// then n the number of samples which give the bandwidth //
// can be (8928 / tone) * 1 or 2 or 3 or 4 etc           //
// init is 8928/558 = 16 *4 = 64 samples                 //
// try to take n = 96 or 128 ;o)                         //
// 48 will give you a bandwidth around 186 hz            //
// 64 will give you a bandwidth around 140 hz            //
// 96 will give you a bandwidth around 94 hz             //
// 128 will give you a bandwidth around 70 hz            //
// BUT remember that high n take a lot of time           //
// so you have to find the compromice - i use 48         //
///////////////////////////////////////////////////////////
float coeff;
float Q1 = 0;
float Q2 = 0;
float sine;
float cosine;  
float sampling_freq=8928.0;
float target_freq=558.0; /// adjust for your needs see above
float n=48.0;  //// if you change  her please change next line also
int testData[48];
//////////////////////////////
// Noise Blanker time which //
// shall be computed so     //
// this is initial          //
//////////////////////////////
int nbtime = 6;  /// ms noise blanker         
long starttimehigh;
long highduration;
long lasthighduration;
long hightimesavg;
long lowtimesavg;
long startttimelow;
long lowduration;
long laststarttime = 0;
char code[20];
int stop = LOW;
int wpm;

////////////////
// init setup //
////////////////
void setup() {
////////////////////////////////////
// The basic goertzel calculation //
////////////////////////////////////
  int  k;
  float omega;
  k = (int) (0.5 + ((n * target_freq) / sampling_freq));
  omega = (2.0 * PI * k) / n;
  sine = sin(omega);
  cosine = cos(omega);
  coeff = 2.0 * cosine;
///////////////////////////////
// define special characters //
///////////////////////////////
 lcd.createChar(0, U_umlaut); //     German
 lcd.createChar(1, O_umlaut); //     German, Swedish
 lcd.createChar(2, A_umlaut); //     German, Swedish
 lcd.createChar(3, AE_capital); //   Danish, Norwegian
 lcd.createChar(4, OE_capital); //   Danish, Norwegian
 lcd.createChar(5, fullblock);        
 lcd.createChar(6, AA_capital); //   Danish, Norwegian, Swedish
 lcd.createChar(7, emtyblock);
 lcd.clear();
 Serial.begin(115200);
 pinMode(ledPin, OUTPUT);
 lcd.begin(colums, rows);
 for (int index = 0; index < colums; index++){
    line1[index] = 32;
  line2[index] = 32;
 }           
message();
}
///////////////
// message   //
/////////////// 
   void message(){ 
    lcd.print("testo, testo");
    delay(1000);
  }  
///////////////
// main loop //
///////////////
 void loop() {
  /////////////////////////////////////
  // The basic where we get the tone //
  /////////////////////////////////////
 
  for (char index = 0; index < n; index++)
  {
    testData[index] = analogRead(audioInPin);
  }
  for (char index = 0; index < n; index++){
    float Q0;
    Q0 = coeff * Q1 - Q2 + (float) testData[index];
    Q2 = Q1;
    Q1 = Q0;  
  }
  float magnitudeSquared = (Q1*Q1)+(Q2*Q2)-Q1*Q2*coeff;  // we do only need the real part //
  magnitude = sqrt(magnitudeSquared);
  Q2 = 0;
  Q1 = 0;
  //Serial.print(magnitude); Serial.println();  //// here you can measure magnitude for setup..
 
  ///////////////////////////////////////////////////////////
  // here we will try to set the magnitude limit automatic //
  ///////////////////////////////////////////////////////////
 
  if (magnitude > magnitudelimit_low){
    magnitudelimit = (magnitudelimit +((magnitude - magnitudelimit)/6));  /// moving average filter
  }
 
  if (magnitudelimit < magnitudelimit_low)
  magnitudelimit = magnitudelimit_low;
 
  ////////////////////////////////////
  // now we check for the magnitude //
  ////////////////////////////////////
  if(magnitude > magnitudelimit*0.6) // just to have some space up
     realstate = HIGH;
  else
    realstate = LOW;
 
  /////////////////////////////////////////////////////
  // here we clean up the state with a noise blanker //
  /////////////////////////////////////////////////////
 
  if (realstate != realstatebefore){
  laststarttime = millis();
  }
  if ((millis()-laststarttime)> nbtime){
  if (realstate != filteredstate){
    filteredstate = realstate;
  }
  }
 
 ////////////////////////////////////////////////////////////
 // Then we do want to have some durations on high and low //
 ////////////////////////////////////////////////////////////
 
 if (filteredstate != filteredstatebefore){
  if (filteredstate == HIGH){
    starttimehigh = millis();
    lowduration = (millis() - startttimelow);
  }
  if (filteredstate == LOW){
    startttimelow = millis();
    highduration = (millis() - starttimehigh);
        if (highduration < (2*hightimesavg) || hightimesavg == 0){
      hightimesavg = (highduration+hightimesavg+hightimesavg)/3;     // now we know avg dit time ( rolling 3 avg)
    }
    if (highduration > (5*hightimesavg) ){
      hightimesavg = highduration+hightimesavg;     // if speed decrease fast ..
    }
  }
  }
 ///////////////////////////////////////////////////////////////
 // now we will check which kind of baud we have - dit or dah //
 // and what kind of pause we do have 1 - 3 or 7 pause        //
 // we think that hightimeavg = 1 bit                         //
 ///////////////////////////////////////////////////////////////
 
 if (filteredstate != filteredstatebefore){
  stop = LOW;
  if (filteredstate == LOW){  //// we did end a HIGH
   if (highduration < (hightimesavg*2) && highduration > (hightimesavg*0.6)){ /// 0.6 filter out false dits
  strcat(code,".");
  Serial.print(".");
   }
   if (highduration > (hightimesavg*2) && highduration < (hightimesavg*6)){
  strcat(code,"-");
  Serial.print("-");
  wpm = (wpm + (1200/((highduration)/3)))/2;  //// the most precise we can do ;o)
   }
  }
 
   if (filteredstate == HIGH){  //// we did end a LOW
   
   float lacktime = 1;
   if(wpm > 25)lacktime=1.0; ///  when high speeds we have to have a little more pause before new letter or new word
   if(wpm > 30)lacktime=1.2;
   if(wpm > 35)lacktime=1.5;
   
   if (lowduration > (hightimesavg*(2*lacktime)) && lowduration < hightimesavg*(5*lacktime)){ // letter space
    docode();
  code[0] = '\0';
  Serial.print("/");
   }
   if (lowduration >= hightimesavg*(5*lacktime)){ // word space
    docode();
  code[0] = '\0';
  printascii(32);
  Serial.println();
   }
  }
 }
 
 //////////////////////////////
 // write if no more letters //
 //////////////////////////////
  if ((millis() - startttimelow) > (highduration * 6) && stop == LOW){
   docode();
   code[0] = '\0';
   stop = HIGH;
  }
 /////////////////////////////////////
 // we will turn on and off the LED //
 // and the speaker                 //
 /////////////////////////////////////
 
   if(filteredstate == HIGH){
     digitalWrite(ledPin, HIGH);
   tone(audioOutPin,target_freq);
   }
   else{
     digitalWrite(ledPin, LOW);
   noTone(audioOutPin);
   }
 
 //////////////////////////////////
 // the end of main loop clean up//
 /////////////////////////////////
 updateinfolinelcd();
 realstatebefore = realstate;
 lasthighduration = highduration;
 filteredstatebefore = filteredstate;
 }

////////////////////////////////
// translate cw code to ascii //
////////////////////////////////
void docode(){
    if (strcmp(code,".-") == 0) printascii(65);
  if (strcmp(code,"-...") == 0) printascii(66);
  if (strcmp(code,"-.-.") == 0) printascii(67);
  if (strcmp(code,"-..") == 0) printascii(68);
  if (strcmp(code,".") == 0) printascii(69);
  if (strcmp(code,"..-.") == 0) printascii(70);
  if (strcmp(code,"--.") == 0) printascii(71);
  if (strcmp(code,"....") == 0) printascii(72);
  if (strcmp(code,"..") == 0) printascii(73);
  if (strcmp(code,".---") == 0) printascii(74);
  if (strcmp(code,"-.-") == 0) printascii(75);
  if (strcmp(code,".-..") == 0) printascii(76);
  if (strcmp(code,"--") == 0) printascii(77);
  if (strcmp(code,"-.") == 0) printascii(78);
  if (strcmp(code,"---") == 0) printascii(79);
  if (strcmp(code,".--.") == 0) printascii(80);
  if (strcmp(code,"--.-") == 0) printascii(81);
  if (strcmp(code,".-.") == 0) printascii(82);
  if (strcmp(code,"...") == 0) printascii(83);
  if (strcmp(code,"-") == 0) printascii(84);
  if (strcmp(code,"..-") == 0) printascii(85);
  if (strcmp(code,"...-") == 0) printascii(86);
  if (strcmp(code,".--") == 0) printascii(87);
  if (strcmp(code,"-..-") == 0) printascii(88);
  if (strcmp(code,"-.--") == 0) printascii(89);
  if (strcmp(code,"--..") == 0) printascii(90);
  if (strcmp(code,".----") == 0) printascii(49);
  if (strcmp(code,"..---") == 0) printascii(50);
  if (strcmp(code,"...--") == 0) printascii(51);
  if (strcmp(code,"....-") == 0) printascii(52);
  if (strcmp(code,".....") == 0) printascii(53);
  if (strcmp(code,"-....") == 0) printascii(54);
  if (strcmp(code,"--...") == 0) printascii(55);
  if (strcmp(code,"---..") == 0) printascii(56);
  if (strcmp(code,"----.") == 0) printascii(57);
  if (strcmp(code,"-----") == 0) printascii(48);
  if (strcmp(code,"..--..") == 0) printascii(63);
  if (strcmp(code,".-.-.-") == 0) printascii(46);
  if (strcmp(code,"--..--") == 0) printascii(44);
  if (strcmp(code,"-.-.--") == 0) printascii(33);
  if (strcmp(code,".--.-.") == 0) printascii(64);
  if (strcmp(code,"---...") == 0) printascii(58);
  if (strcmp(code,"-....-") == 0) printascii(45);
  if (strcmp(code,"-..-.") == 0) printascii(47);
  if (strcmp(code,"-.--.") == 0) printascii(40);
  if (strcmp(code,"-.--.-") == 0) printascii(41);
  if (strcmp(code,".-...") == 0) printascii(95);
  if (strcmp(code,"...-..-") == 0) printascii(36);
  if (strcmp(code,"...-.-") == 0) printascii(62);
  if (strcmp(code,".-.-.") == 0) printascii(60);
  if (strcmp(code,"...-.") == 0) printascii(126);
  //////////////////
  // The specials //
  //////////////////
  if (strcmp(code,".-.-") == 0) printascii(3);
  if (strcmp(code,"---.") == 0) printascii(4);
  if (strcmp(code,".--.-") == 0) printascii(6);
}
/////////////////////////////////////
// print the ascii code to the lcd //
// one a time so we can generate   //
// special letters                 //
/////////////////////////////////////
void printascii(int asciinumber){
int fail = 0;
if (rows == 4 and colums == 16)fail = -4; /// to fix the library problem with 4*16 display http://forum.arduino.cc/index.php/topic,14604.0.html
 
 if (lcdindex > colums-1){
  lcdindex = 0;
  if (rows==4){
    for (int i = 0; i <= colums-1 ; i++){
    lcd.setCursor(i,rows-3);
    lcd.write(line2);
    //line2=line1;
    }
   }
  for (int i = 0; i <= colums-1 ; i++){
    lcd.setCursor(i+fail,rows-2);
    lcd.write(line1);
  lcd.setCursor(i+fail,rows-1);
    lcd.write(32);
  }
 }
 line1[lcdindex]=asciinumber;
 lcd.setCursor(lcdindex+fail,rows-1);
 lcd.write(asciinumber);
 lcdindex += 1;
}
void updateinfolinelcd(){
/////////////////////////////////////
// here we update the upper line   //
// with the speed.                 //
/////////////////////////////////////
  int place;
  if (rows == 4){
   place = colums/2;}
  else{
   place = 2;
  }
  if (wpm<10){
    lcd.setCursor((place)-2,0);
    lcd.print("0");
    lcd.setCursor((place)-1,0);
    lcd.print(wpm);
    lcd.setCursor((place),0);
    lcd.print(" BPM ");
  }
  else{
    lcd.setCursor((place)-2,0);
    lcd.print(wpm);
    lcd.setCursor((place),0);
    lcd.print(" BPM ");
  }
}

 

Link al commento
Condividi su altri siti

:thumb_yello: purtroppo ce da dire che mi sono inceppato sui codici e ho fatto confusione ma per fortuna mi avete soccorso e stavolta... colpito e affondato!

finalmente mi compare il messaggio e ho modificato il tempo del messaggio a 3 secondi, grazie a Cicala e Livio ^_^

ora tocca solo al cambio tono della banda passante in questo caso come posso cambiare mediante un pulsante o interruttore la ricezione tono?

Link al commento
Condividi su altri siti

  • 3 years later...
Aldino Del Fabbro

Salve,Alex,è possibile avere lo schema elettrico del tuo progetto cw decoder?

Mi ha incuriosito la tua discussione,vorrei provare a costruirlo,ti ringrazio

Aldino.

Link al commento
Condividi su altri siti

Per prima cosa questa è una discussione ferma da quasi 4 anni.

Comunque hai già tutto, perchè:

Il 22/10/2016 alle 11:02 , alexcanadair ha scritto:

con un arduino nano e un display 16X2 modello 1602A

abbiato con un microfono o un ingresso jack, v

questa è la parte Hw.

Poi è stato anche riportato il codice.

Da ultimo, ma non ultimo devi leggere il regolamento che hai accettato. Leggendolo vedrai che è vietato accodarsi ad altre discussioni.

Modificato: da Livio Orsini
Link al commento
Condividi su altri siti

Ospite
Questa discussione è chiusa alle risposte.
×
×
  • Crea nuovo/a...