i want to change max and min angle of servo, the + and - button it's all working to decrease or increase the variable, the problem is when i want to show current variable into label (for now its only increase and decrease minAngle value), its not showing anything just the default text
#include <Servo.h>
Servo myServo;
int minAngle = 30;
int maxAngle = 150;
const int joystickPin = A0;
const int servoPin = 9;
void setup(){
Serial.begin(9600);
myServo.attach(servoPin);
myServo.write(map(analogRead(joystickPin), 0, 1023, minAngle, maxAngle));
}
void loop() {
// Read joystick value
int joystickValue = analogRead(joystickPin);
int servoAngle = map(joystickValue, 0, 1023, minAngle, maxAngle);
// Move servo to the mapped position
myServo.write(servoAngle);
delay(15); // Allow servo to move
// Check for Bluetooth commands
if (Serial.available() > 0) {
char command = Serial.read();
// Update min angle if the command is 'm' (decrease) or 'M' (increase)
if (command == 'm') {
minAngle -= 1; // Decrease min angle
if (minAngle < 0) minAngle = 0; // Keep within bounds
Serial.print("Min Angle: ");
Serial.println(minAngle); // Send updated min angle to the Android app
}
else if (command == 'M') {
minAngle += 1; // Increase min angle
if (minAngle > maxAngle) minAngle = maxAngle; // Prevent min from exceeding max
Serial.print("Min Angle: ");
Serial.println(minAngle);
}
// Update max angle if the command is 'x' (decrease) or 'X' (increase)
if (command == 'x') {
maxAngle -= 1; // Decrease max angle
if (maxAngle < minAngle) maxAngle = minAngle; // Prevent max from being less than min
Serial.print("Max Angle: ");
Serial.println(maxAngle);
}
else if (command == 'X') {
maxAngle += 1; // Increase max angle
if (maxAngle > 180) maxAngle = 180; // Keep within bounds
Serial.print("Max Angle: ");
Serial.println(maxAngle);
}
}
}