Ciao a tutti,
mi sono costruito un circuito con Arduino UNO per pilotare un RTx con un Keyer CW;
comando Arduino mandando LOW il pin 10 LINEA e 11 PUNTO; i due pin sono in OUTPUT connessi a 5V HIGH tramite resistenze di pullup da 10 k
Tramite le palette mando LOW uno dei due pin e Arduino chiude un reedrele che pilota il RTx
questo è il prg di prova
[code]
#define VELOC A0 // velocità
#define FREQ A1 // frequenza nota
#define LINEA 10 // linee dash
#define PUNTO 11 // punto dot
#define MANIP 9 // manipolazione RTx oppure Gener nota
#define RTX 12 // pilotaggio rele
#define SPEAK 8 // altoparlante
int tBase = 100; // millisecondi
unsigned long tDur; // durata intervallo
unsigned long tDurLinea; // durata intervallo linea
int tFreq; // frequenza nota
bool nota; // se True ascoltiamo altoparlante se False RTx
long t=0; // x debounce
long tl=0;
long tp=0;
long d_delay=50;
int val=0;
int OldV =0;
int OldF =0;
void setup() {
pinMode(VELOC, INPUT_PULLUP);
pinMode(FREQ, INPUT_PULLUP);
pinMode(LINEA, INPUT);
pinMode(PUNTO, INPUT);
pinMode(MANIP, INPUT_PULLUP);
pinMode(RTX, OUTPUT);
pinMode(SPEAK, OUTPUT);
Serial.begin(9600);
val= analogRead(VELOC); // legge velocita
tDur=map(val, 0, 1023, 100, 1000); // durata battuta in millisecondi
tDurLinea=tDur * 3;
Serial.print("Velocita = ");
Serial.println(val);
val=analogRead(FREQ); // legge frequenza per la nota
tFreq = map(val, 0, 1023, 250, 1500); // può variare tra 250 Hz e 1500 Hz
nota=digitalRead(MANIP); // imposta True = Nota altop. False RTx
Serial.print("Frequenza = ");
Serial.println(val);
}
void loop() {
if(digitalRead(LINEA)==LOW) {
Serial.println("Linea Premuta ");
delay(2000);
// Serial.println("Riprova");
}
if(digitalRead(PUNTO)==LOW) {
Serial.println("Punto Premuto ");
delay(2000);
// Serial.println("Riprova");
}
}
[/code]
come programma è una sciocchezza ma mi sta facendo imbestialire: qquando premo una paletta mi segnala premuto PUNTO o LINEA in maniera casuale
Ecco il monitor:
t21:33:35.436 -> Velocita = 733
21:33:35.436 -> Frequenza = 1016
21:33:52.145 -> Linea Premuta
21:33:56.161 -> Linea Premuta
21:33:59.153 -> Linea Premuta
21:34:02.083 -> Punto Premuto
21:34:04.873 -> Linea Premuta
21:34:07.422 -> Linea Premuta
21:34:10.143 -> Punto Premuto
21:34:12.388 -> Punto Premuto
21:34:14.836 -> Punto Premuto
21:34:17.183 -> Punto Premuto
21:34:19.497 -> Linea Premuta
21:34:21.501 -> Punto Premuto
21:34:23.507 -> Linea Premuta
Tenendo premuta la stessa paletta il pin relativo va a zero (controllato con il tester) ma impulsi successivi li segnala in maniera del tutto arbitraria
Avete idea del perché?
Franco