Arduino Simple Calculator

Hi, Im having trouble with this simple calculator program witch displays two numbers on the screen ( from -10 to 10) using the potentiometer and the rich shield. I also need to display the numbers and the result on the display of the arduino. For the operations I used “a, s, t, d” to represent them.

The problem is that this calculator only allows me to get int type results, operations such as 1/3 giving 0. Do you have any insight that might help? thx

<#include “Display.h”
int mode = 0 ;
int LastButtonState = HIGH;
float value1;
float value2;
int op;
const int POTENTIOMETER = A0;
const int LED_YELLOW = 7;
const int LED_BLUE = 6;
const int LED_GREEN = 5;
const int LED_RED = 4;
const int BUTTON = 8;

void setup() {

Display.on();
Display.show("----");
pinMode(BUTTON, INPUT_PULLUP);
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_YELLOW, OUTPUT);

}

void loop() {
int buttonState;

buttonState = digitalRead (BUTTON);
if (buttonState != LastButtonState) {

if (buttonState == LOW) {

//button pressed
mode ++ ;
}
LastButtonState = buttonState;
}

//Read Potentiometer
int val;
val = analogRead(POTENTIOMETER);

if (mode == 0) {
//do nothing, wait for first press button
}

else if (mode == 1) {

mode = 2;

} else if (mode == 2) {

//input value 1
digitalWrite(LED_BLUE, HIGH);
value1 = map (val, 0, 1023, -10, 10 );
Display.show(value1);

} else if (mode == 3) {

//input operator

op = map (val, 0, 1023, 1, 4 );

if (op == 1) {
Display.show(“a”);
}
else if (op == 2 ) {
Display.show(“s”);
}
else if (op == 3) {
Display.show(“t”);
}
else if (op == 4) {
Display.show(“d”);
}

} else if (mode == 4) {

//input value 2
digitalWrite(LED_BLUE, HIGH);
value2 = map (val, 0, 1023, -10, 10 );
Display.show(value2);

}

else if (mode == 5) {
// show result

float result;

if (op == 1) {
result = value1 + value2;
digitalWrite(LED_BLUE, LOW);
digitalWrite(LED_GREEN, HIGH);
}
else if (op == 2 ) {
result = value1 - value2;
digitalWrite(LED_BLUE, LOW);
digitalWrite(LED_GREEN, HIGH);
}
else if (op == 3) {
result = value1 * value2;
digitalWrite(LED_BLUE, LOW);
digitalWrite(LED_GREEN, HIGH);
}
else if (op == 4) {

if (value2 != 0 ) {
result = value1 / value2;
digitalWrite(LED_BLUE, LOW);
digitalWrite(LED_GREEN, HIGH);
}
else {
Display.show(“Err”);
digitalWrite(LED_BLUE, LOW);
digitalWrite(LED_RED, HIGH);
}
}

Display.show(result);
}

else if (mode == 6 ) { //change the return to mode 2
//back to value 1
mode = 2;

}
}

Maybe float variables?

Please remember to use code tags when posting code.

It looks like the '>' at the end of your code should actually be at the top?