Calculation always zero?

I'm a newbie too, so I hope I've got this right :slight_smile:

See how you go with this code.....your version was subtracting 0 from 0 every time (the variables Ua and Ub are never set after they are declared as 0), so the answer was always going to be zero.

/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

long Ua = 0;
long Ub = 0;
long result=0;


// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0/1:

  Ua = analogRead(A0);
  delay(10);
  Ub = analogRead(A1);
  delay(10);
  result=Ua-Ub;

  // print out the value you read:
  Serial.print("Ua: ");
  Serial.println(Ua);
  Serial.print("Ub: ");
  Serial.println(Ub);
  Serial.print("Dehnung: ");
  Serial.println(result);
}