Fairly new to coding need help

Having trouble with coding (MG996R)servos,3x4matrixkeypad,LCD2004 20x4 and an (lj12a3-4-z /bx) inductive sensor
I 1st want the inductive sensor to activate once activate/sense the (metals) then to print on the lcd 1-6 numbers at the sametime the keypad no.(1-6) will activate different servos(servo1,servo2,servo3,servo4,servo5 and servo6) to rotate 360 and then stop

attach my code so far

Final_coding.ino (4.24 KB)

People are reluctant to open unknown files. At the top of this Forum are several posts that you should probably read, especially about using code tags for posting source code files. Also, before posting your code, you might use Ctrl-T while the cursor is in the IDE's Source Code Window. This will reformat your code to a common C style.

Before looking at your code please tell us in detail what happens when you run it and what you want it to do that is different.

And for short programs please just include the code in your Post using the code button </>

...R

One problem I see with your design:
"activate different servos(servo1,servo2,servo3,servo4,servo5 and servo6) to rotate 360 and then stop"
I don't think your servos are going to turn 360 degrees.

Sorry bout that new to the forum
do i just copy and paste the code here
cant seem to find the code button

once i've upload the the keypad and the inductive sensor is basically not working
only the servos are working (continues rotation)

want to run the inductive sensor 1st once (true)
i will then select 1-6 number on the keypad to run 1 of the servos preferably just 1(360) turn
1-6 number because i was planning on using 6 servos

put code here

Click the button in the red box. Past code between code tags.

code tags.jpg

This is shown in the how to use this forum sticky, see #7.

Continuous servos have lost their feedback element so cannot know their position. So turning exactly 360 degrees is going to be a problem. You might be able to get close with timing, but if the servo load changes the timing will be off.

#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Servo.h>
// Include libraries

LiquidCrystal_I2C lcd(0x27, 20, 4);
// Set the LCD address to 0x27 for a 20 chars and 4 line display

Servo servo1, servo2, servo3, servo4, servo5, servo6;
// defines each servo

int metaldetectorpin = A1;
int capacitivedetectorpin = A2;
int motiondetectorpin = A3;
int ledpin = A4;
int numKeyPresses = 0;            // Track number of key presses
int maxKeyPresses = 1;            // Only allow 3 digits to be entered
int keyPresses[1] = { 0 };        // Initialize an empty array to hold input
const byte ROWS = 4;              //Four rows
const byte COLS = 3;              //Three columns


int buttonPressed;

// defines the keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 11, 10, 9, 8 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 7, 6, 5 };

// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  // put your setup code here, to run once:
lcd.begin(); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the displa

servo1.attach (2);
servo2.attach (3);
servo3.attach (4);
servo4.attach (12);
servo5.attach (13);
servo6.attach (A0);

pinMode (metaldetectorpin, INPUT);
pinMode (capacitivedetectorpin, INPUT);
pinMode (motiondetectorpin, INPUT);

}

void loop() {

 // put your main code here, to run repeatedly:
 // print "Insert Recyclables!" on the LCD
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Insert Recyclables!");

 // Wait until Recyclables is detected
 while (true) {
  if (analogRead(metaldetectorpin) == LOW) {
    // if a recyclables "METALS" is detected, exit the from the while loop
    break; 
  if (analogRead(capacitivedetectorpin) == LOW) {
    // if a recyclables "PLASTICS" is detected, exit the from the while loop
    break;
  if (analogRead(motiondetectorpin) == LOW) {
    // if a recyclables "PAPERS" is detected, exit the from the while loop
    break;
   }
  }
 }
 delay(10);
 lcd.clear();
 lcd.setCursor(0, 0);
 lcd.print("Select your item");
 lcd.setCursor(0, 1);
 lcd.print(" 1, 2, 3, 4, 5, or 6?");
 // Wait until a button is pressed
 {
  char key = keypad.getKey();
  buttonPressed: if(keypad.getKey()) // Check for a valid key
  {
    switch (keypad.getKey())
    {
      case '1':
      digitalWrite(ledpin, LOW);
      servo1.writeMicroseconds(2000); // rotate
       delay(950);
      servo1.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '2':
      digitalWrite(ledpin, LOW);
      servo2.writeMicroseconds(2000); // rotate
       delay(950);
      servo2.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '3':
      digitalWrite(ledpin, HIGH);
      servo3.writeMicroseconds(2000); // rotate
       delay(950);
      servo3.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '4':
      digitalWrite(ledpin, HIGH);
      servo4.writeMicroseconds(2000); // rotate
       delay(950);
      servo4.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '5':
      digitalWrite(ledpin, HIGH);
      servo5.writeMicroseconds(2000); // rotate
       delay(950);
      servo5.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '6':
      digitalWrite(ledpin, HIGH);
      servo6.writeMicroseconds(2000); // rotate
       delay(950);
      servo6.writeMicroseconds(1500); // stop
       delay(500);
      break;

      case '7':
      buttonPressed = 7;
      break;

      case'8':
      buttonPressed = 8;
      break;

      case'9':
      buttonPressed = 9;
      break;

        //...anything else...
        default:
        break;
    }
  }
 }
 lcd.clear(); // Clears the display
 lcd.setCursor(0, 0);
 lcd.print("Please Wait...."); // Prints "Please Wait...."
  delay(950);
 lcd.clear(); // Clears the display
 lcd.setCursor(0, 0);
 lcd.print("Item delivered!"); // Prints "Item delivered!");
  delay(2000);
 }
}

this is the code ive been using