// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#include <LiquidCrystal.h>
#include <EEPROM.h>
char priceArray[] = ""; //to store four digit price + null-byte
char priceRead[] = "";
int i = 0;
#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 pos2 = 0; //apasa
int pos = 0; //litera
int pos1 = 1; //impinge
int servoPosition;
int potiValue;
const int buttonPin = 1;
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)
//String menu[1] = {"KOPY", "menuAuswahl", "Alle"};
char pressKey;
int passState = 0;
int productState = 0;
int passLenght = 0; //keypad passLenght
int lastState = LOW;
int lastState1 = LOW;
int currentState;
int currentState1;
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);
myservoLiter.write(15); ///// pune la litera A sau numar 1
//myservoApasa.detach(); //opreste
myservoApasa.attach(A4);
myservoIMPinge.attach(A5);
myservoIMPinge.write(20);
//myservoIMPinge.detach();
// myservoApasa.write(0);
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()
{
/*test eprom
EEPROM.get(0x0010, pos1);
Serial.println(pos1);
EEPROM.get(0x0010, pos2);
Serial.println(pos2);
EEPROM.put(0x0010, myservoLiter);
*/
//Serial.println(myservoLiter);
lcd.begin(16, 2);
/////////buton/////////
//buton porneste
if (digitalRead(buttonPin) == LOW) {
//(digitalRead(buttonPin) == HIGH)
lcd.setCursor(0, 1);
lcd.print("KOPY:");
}
else
if (digitalRead(buttonPin) == HIGH) {
}
pressKey = mykeypad.getKey();
if (pressKey != NO_KEY) // if any key is pressed
{
lcd.print(pressKey);
if (pressKey) {
lcd.setCursor(cursorColumn, 6); // move cursor to (cursorColumn, 0)
lcd.print(pressKey); // print key at (cursorColumn, 0)
cursorColumn++;
}
}
///////////////////////////////////////////////////// key
switch (pressKey)
{
case NO_KEY:
// nothing to do if no key is pressed Blank Screen
break;
case 'A':
myservoLiter.write(30);
delay(400);
for (pos2 = 0; pos2 <= 180; pos2 += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservoApasa.write(pos2);
// tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
for (pos2 = 180; pos2 >= 0; pos2 -= 1) { // goes from 180 degrees to 0 degrees
myservoApasa.write(pos2);
EEPROM.put(0x0010, pos2); // tell servo to go to position in variable 'pos'
delay(1); // waits 15ms for the servo to reach the position
}
delay(500);
myservoIMPinge.write(pos1 = pos1 + 20);
delay(1);
EEPROM.put(0x0010, pos1);
lcd.setCursor(1, 1);
delay(400);
lcd.print("A");
// lcd.clear();
break;
case ' ':
myservoIMPinge.write(pos1 = pos1 + 20);
delay(15);
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(pos1 = pos1 + 20);
delay(15);
lcd.setCursor(1, 1);
lcd.print("1");
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(pos1 = pos1 + 20);
delay(15);
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(pos1 = pos1 + 20);
delay(15);
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(pos1 = pos1 + 20);
delay(15);
lcd.setCursor(1, 1);
lcd.print("4");
delay(500);
break;// waits 15ms fo
}
//motor();
// 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 );
//vooit motor(){
// char key = keypad.getKey();
// if (key) {
// pos = (pos * 10) + (key - 100);
// i++;
// if (i >= 3) {
// myservoApasa.write(pos);
// pos = 0; i = 0;}