bjr a tous j ai voulu faire un morse qui une fois resolu vous donne un code a chiffre
jusque la pas de soucis mais j ai voulu ajouter servo et key pad!
depuis lors je suis bloquer suite a plusieurs erreurs que je n arrive pas a corriger!
pourrais avoir un peu de clareté et d aide svp merci.
voici le code :
#include <Servo.h>
#include <Keypad.h>
Servo ServoMotor;
const char * password = "13268";
int position = 0;
const byte ROWS = 4;
const byte COLS = 4;
const char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8, 9};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
int i = 0, pos = 0;
const byte Lvert = 11; // led Verte lettre suivante Pin Num 11 -> 150 ohms -> LED Verte -> GND
const byte Lorange = 12; // led Orange point du morse Pin Num 12 -> 150 ohms -> LED Orange -> GND
const byte Lrouge = 13; // led Rouge tiret du morse Pin Num 13 -> 150 ohms -> LED Rouge -> GND
int temps = 900; // pour le morse 0.9s
int temps1 = 60; // pour animation
int cycle = 0; // cycle de lecture
// ************** INIT ********************************************************************
void setup() {
Serial.begin(9600); // pour info, ouvre le port s�rie � 9600 bauds
pinMode(Lvert, OUTPUT); pinMode(Lorange, OUTPUT); pinMode(Lrouge, OUTPUT);
digitalWrite(Lvert, 0); digitalWrite(Lorange, 0); digitalWrite(Lrouge, 0);
ServoMotor.attach(10);
LockedPosition(true); // fermé ok
}
// ************** Debut Prog *************************************************************
void loop() {
// info sur le port s�rie en 9600
Serial.println("\n*************************************************\nInit : OK");
Serial.println("Feu Rouge Morse Version: V1 du 15/08/2019 \nGeocaching Metrix \n");
Serial.print("Code Morse: Orange => point , Rouge => tiret , Vert => lettre suivante \n\nCycle de lecture N: ");
cycle ++ ;
Serial.print(cycle); Serial.print(" tempo en ms = "); Serial.println(temps * 2);
// fin de l'info
animation(); // animation lumineuse des 3 LED
/* Code Morse
A .-
B -...
C -.-.
D -..
E .
F ..-.
G --.
H ....
I ..
J .---
K -.-
L .-..
M --
N -.
O ---
P .--.
Q --.-
R .-.
S ...
T -
U .-
V ...-
W .--
X -..-
Y -.--
Z --..
1 .----
2 ..---
3 ..--
4 ....-
5 .....
6 -....
7 --...
8 ---..
9 ----.
0 -----
*/
// -- d�but message en Morse sur les LED --
Serial.println("\nCoordonn�es : exemple 13268"); // info sur le port serie
point();tiret();tiret();tiret();tiret(); espace(); // 1
point();point();point();tiret();tiret(); espace(); // 3
point();point();tiret();tiret();tiret(); espace(); // 2
tiret();point();point();point();point(); espace(); // 6
tiret();tiret();tiret();point();point(); espace(); // 8
// fin du message Morse
delay(2000);
if (temps < 999) {
temps = temps + 100 ;
}; // vitesse plus lente de 650ms maxi 2.5s
// fin
char customKey = customKeypad.getKey();
if (key == '*' || key == '#')
{
position = 0;
LockedPosition(true);
}
if (customKey){
Serial.println(customKey);
{
position ++;
}
if (position == 6)
{
LockedPosition(false);
}
delay(100);
}
void LockedPosition(boolean locked)
{
if (locked)
{
ServoMotor.write(0);
}
else
{
;
ServoMotor.write(90);
}
}
// ***************** Fin Prog ******************************************************
// ********* point Morse couleur Orange *********
void point() {
digitalWrite(Lorange, 1); delay(2 * temps); digitalWrite(Lorange, 0); delay(temps);
}
// ********* tiret Morse couleur Rouge *********
void tiret() {
digitalWrite(Lrouge, 1 ); delay(2 * temps); digitalWrite(Lrouge, 0 ); delay(temps);
}
// ********* espace Morse couleur Vert *********
void espace() {
digitalWrite(Lvert, 1); delay(2 * temps); digitalWrite(Lvert, 0); delay(temps);
}
// ********* Animation *********
void animation() {
byte x = 0;
for (int x = 0; x < 5; x++) // clignotement des led
{
digitalWrite(Lvert, 1); digitalWrite(Lorange, 1); digitalWrite(Lrouge, 1); delay(temps1);
digitalWrite(Lvert, 0); digitalWrite(Lorange, 0); digitalWrite(Lrouge, 0); delay(temps1);
};
for (int x = 0; x < 3; x++) // chenillard des LED
{
digitalWrite(Lvert, 1); delay(temps1); digitalWrite(Lvert, 0); delay(temps1);
digitalWrite(Lorange, 1); delay(temps1); digitalWrite(Lorange, 0); delay(temps1);
digitalWrite(Lrouge, 1); delay(temps1); digitalWrite(Lrouge, 0); delay(temps1);
digitalWrite(Lorange, 1); delay(temps1); digitalWrite(Lorange, 0); delay(temps1);
}
digitalWrite(Lvert, 1); delay(temps1); digitalWrite(Lvert, 0); delay(temps1);
}
et mes erreurs :
Arduino : 1.8.13 (Windows 10), Carte : "Arduino Uno"
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino: In function 'void setup()':
sketch_sep17hSCFQ:41:3: error: 'LockedPosition' was not declared in this scope
LockedPosition(true); // fermé ok
^~~~~~~~~~~~~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:41:3: note: suggested alternative: 'position'
LockedPosition(true); // fermé ok
^~~~~~~~~~~~~~
position
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino: In function 'void loop()':
sketch_sep17hSCFQ:54:3: error: 'animation' was not declared in this scope
animation(); // animation lumineuse des 3 LED
^~~~~~~~~
sketch_sep17hSCFQ:100:7: error: 'point' was not declared in this scope
point();tiret();tiret();tiret();tiret(); espace(); // 1
^~~~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:100:7: note: suggested alternative: 'uint'
point();tiret();tiret();tiret();tiret(); espace(); // 1
^~~~~
uint
sketch_sep17hSCFQ:100:15: error: 'tiret' was not declared in this scope
point();tiret();tiret();tiret();tiret(); espace(); // 1
^~~~~
sketch_sep17hSCFQ:100:48: error: 'espace' was not declared in this scope
point();tiret();tiret();tiret();tiret(); espace(); // 1
^~~~~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:100:48: note: suggested alternative: 'isSpace'
point();tiret();tiret();tiret();tiret(); espace(); // 1
^~~~~~
isSpace
sketch_sep17hSCFQ:120:5: error: 'key' was not declared in this scope
if (key == '*' || key == '#')
^~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:120:5: note: suggested alternative: 'Key'
if (key == '*' || key == '#')
^~~
Key
sketch_sep17hSCFQ:123:1: error: 'LockedPosition' was not declared in this scope
LockedPosition(true);
^~~~~~~~~~~~~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:123:1: note: suggested alternative: 'position'
LockedPosition(true);
^~~~~~~~~~~~~~
position
sketch_sep17hSCFQ:132:1: error: 'LockedPosition' was not declared in this scope
LockedPosition(false);
^~~~~~~~~~~~~~
C:\Users\andyb\OneDrive\Documents\Arduino\sketch_sep17hSCFQ\sketch_sep17hSCFQ.ino:132:1: note: suggested alternative: 'position'
LockedPosition(false);
^~~~~~~~~~~~~~
position
sketch_sep17hSCFQ:137:1: error: a function-definition is not allowed here before '{' token
{
^
sketch_sep17hSCFQ:187:3: error: expected '}' at end of input
}
^
Plusieurs bibliothèque trouvées pour "Keypad.h"
Utilisé : C:\Users\andyb\OneDrive\Documents\Arduino\libraries\Keypad
Non utilisé : C:\Users\andyb\OneDrive\Documents\Arduino\libraries\arduino_217350
exit status 1
'LockedPosition' was not declared in this scope
merci infiniment