// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#include <LiquidCrystal.h>
#include <Servo.h>
#include <Keypad.h>
#include <LiquidCrystal.h>
const int ROW_NUM = 4; // four rows
const int COLUMN_NUM = 4; // four columns
int cursorColumn = 0;
int seconds = 0;
int pos = 0;
int pos1 = 1;
int servoPosition;
int potiValue;
int i = 0;
const int buttonPin = 12;
const unsigned int BUTTON_WERT_VOR_PIN = 11;
const unsigned int BUTTON_WERT_RUECK_PIN = 10; // Pin für Button um den Wert zu wählen (rückwärts durch gehen)
int menuAuswahl = 0;
//String menu[1] = {"KOPY", "menuAuswahl", "Alle"};
char pressKey;
int passState = 0;
int productState = 0;
int passLenght = 0; //keypad passLenght
int lastState = LOW;
int currentState;
Servo myservoLiter;
Servo myservoApasa;
Servo myservoIMPinge;
char keys[ROW_NUM][COLUMN_NUM] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', ' ', 'D'}
};
byte pin_rows[ROW_NUM] = {A0, A1, A2, A3}; // connect to the row pinouts of the keypad
byte pin_column[COLUMN_NUM] = {5, 4, 3, 2}; // connect to the column pinouts of the keypad
Keypad mykeypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
//Adafruit_LiquidCrystal lcd_1(0); // I2C address 0x27, 16 column and 2 rows
void setup()
{
// aktualisiereLcd();
lcd.begin(16, 2);
Serial.begin(9600); //fac legatura cu monitor
myservoLiter.attach(6); //servo ca obiect:
myservoApasa.attach(A4);
myservoIMPinge.attach(A5);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(BUTTON_WERT_VOR_PIN, INPUT_PULLUP);
//lcd_1.setCursor(0, 2); // Erste Zeile: Helligkeit für R G B anzeigen.
// lcd_1.print("KOPY:");
}
void loop()
{
lcd.begin(16, 2);
pressKey = mykeypad.getKey();
if (pressKey != NO_KEY) // if any key is pressed
{
lcd.print(pressKey);
}
switch (pressKey)
{
case NO_KEY:
// nothing to do if no key is pressed Blank Screen
break;
case 'A':
myservoLiter.write(30);
delay(400);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}
delay(500);
for (pos1 <= 0; pos1 +1;) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
pos1 +1;
myservoIMPinge.write(pos);
delay(5);
}
lcd.setCursor(1, 1);
lcd.print("A");
delay(400);
lcd.clear();
break;
case ' ':
myservoIMPinge.write(120);
lcd.setCursor(1, 1);
lcd.print("_");
delay(400);
lcd.clear();
break;
case '1':
myservoLiter.write(100);
delay(400);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
myservoIMPinge.write(20);
lcd.setCursor(1, 1);
lcd.print("1");
delay(500);
break;// waits 15ms for the servo to reach the position
case '2':
myservoLiter.write(160);
delay(400);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
myservoIMPinge.write(20);
lcd.setCursor(1, 1);
lcd.print("2");
delay(500);
break;// waits 15ms fo
case '3':
myservoLiter.write(35);
delay(400);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
myservoIMPinge.write(20);
lcd.setCursor(1, 1);
lcd.print("3");
delay(500);
break;// waits 15ms fo
case '4':
myservoLiter.write(25);
delay(400);
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
myservoIMPinge.write(20);
lcd.setCursor(1, 1);
lcd.print("4");
delay(500);
break;// waits 15ms fo
}
// handleButtons();
// currentState = digitalRead(buttonPin); //buton porneste
// if (lastState == HIGH && currentState == LOW) {
// lcd.setCursor(0, 1);
// }
// if (lastState == LOW && currentState == HIGH) {
// lcd.clear();
// lcd.setCursor(cursorColumn, 0);
// }
// lastState = currentState;
// char key = mykeypad.getKey();
// if (key) {
// lcd_1.setCursor(cursorColumn, 0); // move cursor to (cursorColumn, 0)
// lcd_1.print(key); // print key at (cursorColumn, 0)
// cursorColumn++;
// lcd_1.setCursor(1, 3);
// } // move cursor to next position
//if (cursorColumn == 26) { // if reaching limit, clear LCD
// cursorColumn = 0;
// lcd_1.setCursor(1, 3);
// delay(500);
}
//}
//int inByte = keypad.getKey();
//switch (char Key );
void aktualisiereLcd() {
lcd.setCursor(0, 1); // Erste Zeile: Helligkeit für R G B anzeigen.
lcd.print("KOPY: ");
//lcd.print(helligkeit[0]);
lcd.print(" ");
}
// vooit motor (){
// char key = keypad.getKey();
// if (key) {
// pos = (pos * 10) + (key - 100);
// i++;
// if (i >= 3) {
// myservoApasa.write(pos);
// pos = 0; i = 0;