I just used multiKey, but the only thing that is happening, is that the LCD shows when a key is pushed, released of idled, but nothing happens to the steppers...
This is what I had in mind to program, the project is about a automatic garage with 8 places. If you push a number from 1 to 8, a system should take a platform where you can park your car.
For example... If I push '1' on the keypad, an arm takes out a platform from parkingspot number 1. Because I don't use sensors it's possible that the parkingspot is already taken, so if there is already a car on the platform you need to push '1' but also '*' so the arm places back the platform in the right spot.
If the platform is empty, you can ride your car on it, once you are out your car you need to push '1' and '#' to put the platform back in parkingspot 1.
The program isn't for real life cars, but with 3D-printed cars.
#include <Stepper.h>
#define STEPS 2038 // aantal stappen per rotatie (28BYJ-48)
Stepper motor1 (STEPS, 2, 4, 3, 5); // Motor 1 met: IN1->2, IN2->3, IN3->4, IN4->5
Stepper motor2 (STEPS, 6, 8, 7, 9); // Motor 2 met: IN1->6, IN2->7, IN3->8, IN4->9
Stepper motor3 (STEPS, 10, 12, 11, 13); // Motor 3 met: IN1->10, IN2->11, IN3->12, IN4->13
#include <Keypad.h>
const byte ROWS = 4; //Aantal rijen
const byte COLS = 3; //Aantal kolommen
char keys[ROWS][COLS] = { //Cijfers invoeren volgens de keypad
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {22, 24, 26, 28}; //Rijen verbinden met Arduino
byte colPins[COLS] = {30, 32, 34}; //Kolommen verbinden met Arduino
Keypad keypad = Keypad (makeKeymap(keys), rowPins, colPins, ROWS, COLS);
#include <LiquidCrystal.h>
LiquidCrystal lcd (36, 38, 40, 42, 44, 46);
void setup() {
lcd.begin (16,2);
lcd.setCursor(2,0);
lcd.print("Vives Brugge");
lcd.setCursor(5,1);
lcd.print("Welkom");
}
void loop() {
char key = keypad.getKey ();
if(int(key) !=0) {
if(int(key)=='1'){ // the arm gets the platform
lcd.begin (16,2);
lcd.setCursor(3,0);
lcd.print ("Even geduld");
lcd.setCursor(1,1);
lcd.print ("Platform halen");
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
lcd.begin (16,2);
lcd.print("Vrij? druk 1#");
lcd.setCursor(0,4);
lcd.print("Anders 1*");
}
if(int(key)==('1'&&'*')){ // the parkingspace is full, after you push '1' and '*' the car will go to parkingspace 1
lcd.begin (16,2);
lcd.print ("Even geduld");
lcd.setCursor(0,0);
lcd.print ("Platform plaatsen");
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
lcd.begin (16,2);
lcd.setCursor(2,0);
lcd.print("Vives Brugge");
lcd.setCursor(5,1);
lcd.print("Welkom");
}
if(int(key)=='1'&&'#'){ //the parkingspace is empty, you can put your car on it, after you push '1' and '*' the car will go to parkingspace 1
lcd.begin (16,2);
lcd.print ("Even geduld");
lcd.setCursor(0,1);
lcd.print ("U wagen plaatsen");
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor1.setSpeed(15); // 15 toeren per minuut
motor1.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor2.setSpeed(15); // 15 toeren per minuut
motor2.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(2038); // draai 2038 stappen
delay(500); // wacht 0,5 seconden
motor3.setSpeed(15); // 15 toeren per minuut
motor3.step(-2038); // draai 2038 stappen in de negatieve zin
delay(500); // wacht 0,5 seconden
lcd.begin (16,2);
lcd.setCursor(2,0);
lcd.print("Vives Brugge");
lcd.setCursor(5,1);
lcd.print("Welkom");
}
}
}