-1

Since this is this the first time im doing Arduino, im really confused what the code is to:

write a code which reads the value(nae the value 'flexValue') of a flex sensor connected to analog input AN0.

The value should be a 10-bit integer number having value between 0-1023, inclusive.

Ann
  • 1
  • 4

1 Answers1

1

You should call the function analogRead(), and pass the value of A0 into it because you want to read pin A0. For example:

flexVal = analogRead(A0);

The function analogRead() will return a value from 0-1023, just as you require.

When you call this function, the CPU configures the on-board ADC (analog-to-digital converter) to take a reading from pin A0. The ADC on the Arduino has 10-bit resolution, so it will return a value from 0-1023.