Braitenberg vehicle, change modes

Hi guys.. I have to do Braitenberg vehicle with changing modes(from fear to love) I want to code "change" from this

leftServo.write(90 + rightValue); rightServo.write(90 - leftValue);

to this

leftServo.write(90 - rightValue); rightServo.write(90 + leftValue);

with buttons. Is there a any willing person to help me how code will look like? (I already have working engagement, with no buttons) Full code:

include "Servo.h"

Servo leftServo; Servo rightServo; int leftValue = 0; int rightValue = 0;

void setup() { pinMode(buttonPin, INPUT);

leftServo.attach(10); rightServo.attach(9); }

void loop() { // sensor values between 50..900 leftValue = (analogRead(0) - 50) / 50; rightValue = (analogRead(1) - 50) / 50; leftServo.write(90 + rightValue); rightServo.write(90 - leftValue);

X leftServo.write(90 - rightValue); rightServo.write(90 + leftValue);

A button implies (to me) a momentary action switch.

Try a simple, single pole toggle. Much simpler programming, and no need for a mode indicator.

Please remember to use code tags when posting code

The Arduino IDE has simple code for reading buttons and switches, and there are tutorials on line.

  // sensor values between 50..900

Did you mean to say "// sensor values between -1..19" because that is what you are calculating.