Trouble with programming ttp229 keypad to control 4 servos

Hello everybody
I have problem with my arduino program, I want to control 4 servos using a ttp229 keypad, but I can't write a good program for this and I dont know what to do.

In my actually program, IDE consol show me that comunicate

exit status 1
'SERVO1_PIN' does not name a type

Do you have any idea how to fix it ? Maybe whole program is wrong. I'm beging for help.
This is the printscreens of my program:

I'm just geting my first step with programing and I need this program to control robot arm to school to get some special grade.

Sorry for my English I'm from Poland

// MeArm controlled by TTP229-BSF 16-key capacitive touchpad
// by Alan Wang

#include <Servo.h>

// VCC -> 3.3V
// GND -> GND
// SCL -> 13
// SDO -> 12
#define SCL_PIN               13
#define SDO_PIN               12
Servo SERVO1_PIN;
Servo SERVO2_PIN;
Servo SERVO3_PIN;
Servo SERVO4_PIN;
// servo and touchpad settings
SERVO1_PIN.attach(3);             // base servo (servo 1)
SERVO2_PIN.attach(5);   // right side servo (servo 2)
SERVO3_PIN.attach(6);               // left side servo (servo 3)
SERVO4_PIN.attach(9);   // claw servo (servo 4)
#define SERVO1_TO_MIN_KEY     11  // Touchpad key for moving servo 1 toward min position
#define SERVO1_TO_MAX_KEY     10  // Touchpad key for moving servo 1 toward max position
#define SERVO2_TO_MIN_KEY     8   // Touchpad key for moving servo 2 toward min position
#define SERVO2_TO_MAX_KEY     4   // Touchpad key for moving servo 2 toward max position
#define SERVO3_TO_MIN_KEY     5   // Touchpad key for moving servo 3 toward min position
#define SERVO3_TO_MAX_KEY     1   // Touchpad key for moving servo 3 toward max position
#define SERVO4_TO_MAX_KEY     13  // Touchpad key for cycling servo 4 between min/max position
#define SERVO4_TO_MIN_KEY     14 
#define MEARM_TO_DEFAULT_KEY  16  // Touchpad key for turning all servos to default position
int pos1=90;
int pos2=90;
int pos3=90;
int pos4=90;

// variables


int keypad[16];
int key_mapping[3][2] = {{SERVO1_TO_MIN_KEY, SERVO1_TO_MAX_KEY}, {SERVO2_TO_MIN_KEY, SERVO2_TO_MAX_KEY}, {SERVO3_TO_MIN_KEY, SERVO3_TO_MAX_KEY}};


// read the status of touchpad
void readKeypad() {

  for (int i = 0; i < 16; i++) {
    digitalWrite(SCL_PIN, LOW);
    keypad[i] = digitalRead(SDO_PIN);
    Serial.print(keypad[i]);
    digitalWrite(SCL_PIN, HIGH);
  }
  Serial.println("");
}


// initialization
void setup() {

  Serial.begin(9600);
  pinMode(SCL_PIN, OUTPUT);
  pinMode(SDO_PIN, INPUT);

SERVO1_PIN.write(pos1);
SERVO2_PIN.write(pos2);
SERVO3_PIN.write(pos3);
SERVO4_PIN.write(pos4);
delay(250);
  }



// main program
void loop() {

  // read the status of touchpad
  readKeypad();

  // first servo
  if (keypad[SERVO1_TO_MIN_KEY - 1] == 0) {
    ++pos1;
    SERVO1_PIN.write(pos1);
    delay(50); 
  }  
  if(keypad[SERVO1_TO_MAX_KEY - 1] == 0) {
    --pos1;
    SERVO1_PIN.write(pos1);
    delay(50);
    }
   // second one
     if (keypad[SERVO2_TO_MIN_KEY - 1] == 0) {
    ++pos2;
    SERVO2_PIN.write(pos2);
    delay(50); 
  }  
  if(keypad[SERVO2_TO_MAX_KEY - 1] == 0) {
    --pos2;
    SERVO2_PIN.write(pos2);
    delay(50);
    }
   // third one
   if (keypad[SERVO3_TO_MIN_KEY - 1] == 0) {
    ++pos3;
    SERVO3_PIN.write(pos3);
    delay(50); 
  }  
  if(keypad[SERVO3_TO_MAX_KEY - 1] == 0) {
    --pos3;
    SERVO3_PIN.write(pos3);
    delay(50);
    }  
   // fourth
    if (keypad[SERVO4_TO_MIN_KEY - 1] == 0) {
    ++pos4;
    SERVO1_PIN.write(pos4);
    delay(50); 
  }  
  if(keypad[SERVO4_TO_MAX_KEY - 1] == 0) {
    --pos4;
    SERVO1_PIN.write(pos4);
    delay(50);
    }

(deleted)

I'm so sorry

Don't just apologise, post the actual code here...but first read How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum particularly #7 and post it using </> code tags.

Then you'll get plenty of help.

Steve

Code tags would have stopped half of your code being in italics.

Your .attach() commands need to be inside a function. Put them in setup(). And I don't think you really want to write to SERVO1_PIN when the SERVO4 buttons are pressed.

Steve

Thank you I write attach() in setup and it works. Sorry for this mess with code that was my first post. I will be more careful in the future.

Yeah, I dont saw that mistake :slight_smile: . I'm just beginning. I have one more question. What do you think about that how I wrote this program?

Well I would not use _PIN names for things that are Servo objects and nothing like pins. It is confusing. I would use something like Servo1, Servo2 etc.

I'm not sure why you have numbered your touchpad keys so that you always need to subtract 1 when you use them. It would have been easy enough to set them up as 0 - 15 instead.

You could also make more use of arrays but your program is easy enough to understand, which is a good thing. And if it does what you want it to then you deserve to be congratulated.

Steve