Help with Arduino pot trigger

Hello there I was wondering how I can make it so a potentiometer triggers another servo to move 45 degrees and back after the potent. turns another servo 110 degrees or so. Here’s my coding that Ive been working on and just cant get the darn thing to compile. Any help would be greatly appreciated:)

#include <Servo.h>

Servo myservo;
Servo myservo2;// create servo object to control a servo

int pos;// postion of servo
int potpin = 0; // analog pin used to connect the potentiometer

void setup()
{
myservo.attach(9);
myservo2.attach(4);
}

void loop()
{
myservo.write(map(analogRead(potpin), 0, 1023, 0, 179));
delay(15);

myservo2.write(map(analogRead(potpin) < 110);pos = 90));
myservo2.write(map(analogRead(potpin) > 110);pos = 45));

A comparison in a map? What are you rying to do?

myservo.write(map(analogRead(potpin), 0, 1023, 0, 179));

Since you clearly don't know what you are doing (no offense intended), this is not the best way to be writing code. How could you possibly check whether you are reading the correct value from the potentiometer? Perhaps it isn't even connected correctly.

What if your potentiometer is not returning the full range of values?

Change this to three lines.

int potVal = analogRead(potPin);
int mapVal = map(potVal, 0, 1023, 0, 179);
myservo.write(mapVal);

Now, when you copy and paste the code, you can clearly see which value you need to use in the if test.

I'll leave it to you to try re-writing the rest of the code. If you get stuck, come on back with your next attempt, and we'll help you get is working.

thankyou and yes im trying my best. I found it easier to write what I want it to do theoretically but the darn servo doesnt trigger after i give an input from the pot. here’s the code…

#include <Servo.h>

Servo myservo;
Servo myservo2;// create servo object to control a servo

int pos;// postion of servo
int potpin = 0; // analog pin used to connect the potentiometer

void setup()
{
myservo.attach(9);
myservo2.attach(4);
}

void loop()
{
int potVal = analogRead(potpin);
int mapVal = map(potVal, 0, 1023, 0, 179);
myservo.write(mapVal);
delay(15);
{
mapVal < 110;
myservo2.write(90);
delay(15);
}
mapVal > 110;
myservo2.write(45);
delay(15);
}

mapVal < 110;

I think you want an ‘if’ here:

if (mapVal < 110) {
    myservo2.write(90);
    delay(15);
}

Your code will compile, but it won’t do anything useful.

OH m ygod! it works thankyou!@$