Hi,
Vorab ich bin neu hier, und Blutiger Anfänger im umgang mit dem Arduino. ![]()
Ich habe mir gedacht, vielleicht kann mir hier einer bei meinem Problem helfen. Ich würde gerne mein Programm so ändern, dass ich auf Knopfdruck einen anderen Programmteil ausführe. Dieser Knopfdruck soll dann durch ein Board ersetzt werden was an einem UNO hängt und einen Kontakt HIGH setzt. Wenn dieses einen Stromausfall hat, (der Kontakt vom UNO somit LOW) soll das UNO dies Merken und einen bestimmten Programmpunkt ausführen. Wie genau kann ich das umsetzen? Leider habe ich noch keine Möglichkeit so richtig im Netz gefunden. Ich hoffe, ich habe das halbwegs verständlich formuliert.
Unten ist mal mein Programm.
#include <Keypad.h>
char* secretCode = "3007"; // Sicherheitscode
int position = 0; //Variable
const byte rows = 4; //Reihen des Keypads
const byte cols = 4; //Spalten des Keypads
char keys[rows][cols] =
{
{'1','2','3','A',},
{'4','5','6','B',},
{'7','8','9','C',},
{'*','0','#','D',}
};
byte rowPins[rows] = {1, 2, 3, 4}; //Digitale Pinbelegung am Arduino der Reihen des Keypads
byte colPins[cols] = {5, 6, 7, 8}; //Digitale Pinbelegung am Arduino der Spalten des Keypads
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
int redPin = 10; //Pin 10 rote LED
int greenPin = 9; //Pin 9 grüne LED
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
setLocked(true);
}
void loop()
{
char key = keypad.getKey();
if (key == '*' || key == '#')
{
position = 0;
setLocked(true);
}
if (key == secretCode[position])
{
position ++;
}
if (position == 4) //Stellen des Sicherheitscodes
{
setLocked(false);
}
delay(100);
}
void setLocked(int locked)
{
if (locked)
{
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
}
else
{
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
}
}
Tim