#include int motorPin1 = 5; // One motor wire connected to digital pin 50 int motorPin2 = 6; // One motor wire connected to digital pin 52 const byte ROWS = 2; //four rows const byte COLS = 1; //four columns //define the cymbols on the buttons of the keypads char hexaKeys[ROWS][COLS] = { {'2'}, {'1'} }; byte rowPins[ROWS] = {3, 2}; //connect to the row pinouts of the keypad byte colPins[COLS] = {4}; //connect to the column pinouts of the keypad //initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); void setup(){ Serial.begin(9600); } void loop(){ char customKey = customKeypad.getKey(); switch (customKey) { case '1': Serial.println("Rotates To Left"); rotateLeft(); break; case '2': Serial.println("Rotates To Right"); rotateRight(); break; } } void rotateLeft(){ digitalWrite(motorPin1, HIGH); //rotates motor digitalWrite(motorPin2, LOW); // set the Pin motorPin2 LOW } void rotateRight(){ digitalWrite(motorPin2, HIGH); //rotates motor digitalWrite(motorPin1, LOW); // set the Pin motorPin1 LOW }