Help With Using V2 Voice Module & Controlling a Servo

Hello everyone I’m very new to Arduino. I’ve found some tutorials online on how to use the V2 voice module and control some leds. I also set up a small code and circuit to operate my servo to 3 positions, using inputs from pushbuttons. What I’m trying to do now is merge both those programs into one, and have the Outputs from the V2 become my inputs for my servo. I have all 3 sets of code, and I’m wondering if anyone could take a look at my code and tell me where I’m going wrong. Any help would be greatly appreciated.

The Problem Code below: (Also I attached my servo code and voice code that are currently working, and which I’m trying to merge together)

int button7= 9;
int button6= 10;
int button5= 11;

int redPin = 9;
int greenPin = 10;

int bluePin = 11; byte

com = 0; //reply from voice recognition

#include <Servo.h>

Servo myservo;
int pos=0;

void setup() { Serial.begin(9600);

pinMode(redPin, INPUT);

pinMode(greenPin, INPUT);

pinMode(bluePin, INPUT);

myservo.attach(5);

delay(2000);

Serial.write(0xAA);

Serial.write(0x37);

delay(1000);

Serial.write(0xAA);

Serial.write(0x21);

}

void loop()

{

while(Serial.available())

{

com = Serial.read();

switch(com)

{

case 0x11:

digitalWrite(redPin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

break;

case 0x12:

digitalWrite(greenPin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

break;

case 0x13:

digitalWrite(bluePin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

break;

case 0x14:

digitalWrite(redPin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

digitalWrite(greenPin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

digitalWrite(bluePin, HIGH);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

break;

case 0x15:

digitalWrite(redPin, LOW);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

digitalWrite(greenPin, LOW);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

digitalWrite(bluePin, LOW);

button7=digitalRead(redPin);
button6=digitalRead(greenPin);
button5=digitalRead(bluePin);

if(button7==1 && button6==1 && button5==1)
myservo.write(0);

if(button7==1 && button6==0 && button5==1)
myservo.write(90);

if(button7==0 && button6==1 && button5==1)
myservo.write(145);

if(button7==1 && button6==1 && button5==0)
myservo.write(180);

break;


}

}

}

EDIT BY MOD: code included in the proper tags

int bluePin = 11; byte

com = 0; //reply from voice recognition

What possessed you to split this declaration between two lines? Why can't you post code correctly? Why can't you indent code correctly?

What does the code actually do? How does that differ from what you want it to do?

PaulS: ``` int bluePin = 11; byte

com = 0; //reply from voice recognition



What possessed you to split this declaration between two lines?
Why can't you post code correctly?
Why can't you indent code correctly?

What does the code actually do? How does that differ from what you want it to do?

That was how the code was written off an instructable.

Why can't you read the first sentence of my post?

Why can't you provide examples of proper code?

I figured it out thanks.

Penn920: I figured it out thanks.

So how about explaining your solution for the benefit of others ?

...R