So um zum Array Problem zurück zu kommen: Hier bin ich nun
byte array [26] [26] = {
{0b00101, 0b11000, 0b11010, 0b01100, 0b00010, 0b10010, 0b01110, 0b10000, 0b00100, 0b10111, 0b01101, 0b10100,
0b00111, 0b00110, 0b01111, 0b10110, 0b11101, 0b01010, 0b01000, 0b00011, 0b01001, 0b10001, 0b01011, 0b11001, 0b11011, 0b11100},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26}
};
const char b_array[26] = {"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"};
Kommt ein Fehler, dass const char [] zu viele Enterys hat...
Muss ich jetz splitten ?? Sprich wenn ausgabe aus array über 4 ist gehe in e-f_array etc? Oder gibt es da eine sinnvollere Lösung?
Kann euch auch mal gerne mein bisheriges werk präsentieren ^^
unsigned long time;
int sensor = A0,
ma_count = 0, // Array Position hochzählen / zuweisen
strich = 1,
punkt = 0;
byte signal = 0, // Signal ja/nein
wert = 0, // 0= Pause 1= Kurz 2= Lang 3= Zeilenwechsel
code;
char ausgabe;
byte array [26] [26] = {
{0b00101, 0b11000, 0b11010, 0b01100, 0b00010, 0b10010, 0b01110, 0b10000, 0b00100, 0b10111, 0b01101, 0b10100,
0b00111, 0b00110, 0b01111, 0b10110, 0b11101, 0b01010, 0b01000, 0b00011, 0b01001, 0b10001, 0b01011, 0b11001, 0b11011, 0b11100},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26}
};
const char b_array[26] = {"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"};
void setup()
{
Serial.begin(9600);
// time = millis();
code = 0b00001;
}
void loop()
{
if ( signal == 0 && analogRead(sensor) > 100)
{
signal = 1;
time = millis();
while ( analogRead(sensor) > 100)
{}
if ( millis() - time >= 2000 ) // Pause 2 sec -> Zeilenumbruch
{ wert = 3; } // Zeilenumbruch
else
{char ausgabe;
ausgabe = moersetable(code);
Serial.print(ausgabe);
}
}
if ( signal == 1 && analogRead(sensor) <= 100)
{
signal = 0;
time = millis();
while ( analogRead(sensor) <= 100)
{}
if ( millis() - time > 450 ) // Lang
{ code = code << 1 | strich;}
else // Kurz
{code = code << 1 | punkt;}
}
}
byte moersetable(byte code){
// steht bereits im Head, aber kann hier vielleicht besser angebracht sein
/* byte array [26] [26] = {
{0b00101, 0b11000, 0b11010, 0b01100, 0b00010, 0b10010, 0b01110, 0b10000, 0b00100, 0b10111, 0b01101, 0b10100,
0b00111, 0b00110, 0b01111, 0b10110, 0b11101, 0b01010, 0b01000, 0b00011, 0b01001, 0b10001, 0b01011, 0b11001, 0b11011, 0b11100},
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26}
};
const char b_array[26] = {"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"};
*/
byte pos;
char result;
pos = array[code];
result = b_array[pos];
return result;
}
Und den Fehler Code den ich dazu bekomme:
Morse_Entschl_ssler_2:16: error: too many initializers for 'const char [26]'
Morse_Entschl_ssler_2.cpp: In function 'byte moersetable(byte)':
Morse_Entschl_ssler_2:72: error: invalid conversion from 'byte*' to 'byte'
Ich weiß auch noch nicht genau wie ich aus meinem 2D Byte Array dann eine positions angabe im Alphabet array machen kann..
Gruß Flo[/code]