chipKIT® Development Platform

Inspired by Arduino™

analog read MPIDE

Created Wed, 21 Nov 2012 09:38:51 +0000 by ajitnayak


Wed, 21 Nov 2012 09:38:51 +0000

I am using mpide IDE i wanna run simple analog read function from Arduino but due voltage level difference i could not able get answer

Please let me know how can ac

void setup()
  pinMode(A0, INPUT) ;

void loop()
int Sensor_Value;
int voltage;
voltage = Sensor_Value * (3.3 / 1023.0);
  Serial.println("voltage is :\n");


Wed, 21 Nov 2012 10:49:00 +0000

It would help if you were actually reading the input. The voltage difference has nothing to do with it.

Where, in your program, is there an analogRead() ?

Here's a list of very elemental mistakes:

  1. No analogRead(), so SensorValue never gets a value.
  2. println adds the "\n" for you, you don't need to add one yourself.
  3. Using floating point numbers in integer mathematics is not going to give the results you desire.
  4. Setting a pin to INPUT only affects digital IO, not analog.