Trouble with compiling Arduino program to control two servos with 10 set postions any pointers where I am going wrong?

I am having trouble getting this program to compile I have rewriting from the top but i cant get it to work

const int btnRearuppin = 2;
const int btnReardownpin = 3;
const int btnfrontuppin = 4;
const int btnfrontdownpin = 5;
const int maxreargear = 10;
int btnRearupmode = 0
,btnReardownmode = 0
,btnfrontupmode = 0
,btnfrontdownmode = 0
#include <Servo.h>
Servo frontGearservo; // create servo object to control a servo
int frontgear = 0; // variable to store the servo position
Servo reargearservo;
int rearGear = 10;
const int maxRearGears = 10;
const int minRearGears = 1;
const int frontgearmax = 2;
const int frontgearmin = 1;

int btnRearupState; // the current reading from the input pin
int lastbtnRearupState = LOW;
int btnReardownstate;
int lastbtnReardownState = LOW;
int btnfrontupstate;
int lastbtnfrontupState = LOW;
int btnfrontdownstate;
int lastbtnfrontdownState = LOW;

long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers

void setup()


//Possible positions of the front derailleur for gears 1 - 8 when on small front sprocket
int frontGear1[] = {121, 121, 120, 119, 119, 118, 117, 116, 116, 116};
//Possible positions of the front derailleur for gears 1 - 8 when on large front sprocket
int frontGear2[] = { 97, 97, 96, 95, 94, 93, 92, 92, 92, 92};
//Positions of the rear derailleur for gears 1 through 8
int rearGears[] = {132, 125, 116, 105, 96, 84, 73, 62, 55, 49};

void loop() {
int reading = digitalRead(btnRearuppin);
if(btnRearupState = HIGH) {//you clicked a button

// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
if (reading != lastbtnRearupState) {
// reset the debouncing timer
lastDebounceTime = millis();

if(rearGear < maxRearGears){ //if we still have gears left to shift to
rearGear++; //increment to the next gear
moveServos(frontGearservo, reargearservo); //tell the servos to move
else {
btnRearUpPressed = false; //confirm that the button is no longer pressed
btnRearUpDebounceCnt = 0; //reset debounce

{boolean moveServos(int front, int rear)
//get the new position of the rear servo
rearServoPos = rearGears[rear - 1];
//get the new position of the front servo
if(front == 1)
frontServoPos = frontGear1[rear - 1];
frontServoPos = frontGear2[rear - 1];

//move the front and rear servos
//wait for the servos to reach their position.
return true;}

Thanks in advance

ddemayo7 months ago

im guessing maewert is on to something. Here is a tip try using simpler naming conventions in your code and the. Comment your code to see what it is doing instead of trying to both at once. It'll make finding errors easier and you can write whatever you want in comments

maewert6 years ago

Too many programming errors to list here. 
Variables used w/o being declared, incorrect scope for vars, Case matters, etc.

The attached version compiles at least.

Best Wishes

Yeah, post the error messages.
vishalapr6 years ago
A better place to give this problem would be in the arduino forums:

What I think the problem is that its not the code that is wrong or anything but its the connection from the arduino to your pc!

When you try and compile and send it to the arduino do you receive any error message?If so could you please show what the error message is...

So answer my question and I will try to see what the problem is!