Analog inputs oscilating

Hello everyone. I am using a simples code to light a LED according to an analogRead.

The problem is, even when I connect the AnalogInput straight to the 5V output of the Arduino, what I get from analogRead (instead of a constant 1023 and the LED always on) is wha t seems like a sine wave, oscillating between 0 to 1023.

Can anyone help me with that? :confused:

Thank you very much!

Code?
Schematic?

The code is below

int fsrAnalogPin = 0; // FSR is connected to analog 0
int LEDpin = 11; // connect Red LED to pin 11 (PWM pin)
int value; // the analog reading from the FSR resistor divider
int LEDbrightness;

void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
pinMode(LEDpin, OUTPUT);
}

void loop(void) {
value = analogRead(AnalogPin);
Serial.print("Analog reading = ");
Serial.println(value);

// we'll need to change the range from the analog reading (0-1023) down to the range
// used by analogWrite (0-255) with map!
LEDbrightness = map(value, 0, 1023, 0, 255);
// LED gets brighter the harder you press
analogWrite(LEDpin, LEDbrightness);

delay(100);
}

And the schematic, well, now I just have A0 connected to Arduino's 5V output and a LED+Resistor connected to PWM pin 11.

That code is either incomplete or does not compile - AnalogPin is undefined (you've defined fsrAnalogPin, but you refer to AnalogPin in your code)

Also, map(value,0,1023,0,255); can be turned into value>>2;

Also, map(value,0,1023,0,255); can be turned into value>>2;

Or you could write it more naturally as "value /= 4", and the compiler will turn it into "value >>= 2" for you

The problem is, even when I connect the AnalogInput straight to the 5V output of the Arduino, what I get from analogRead (instead of a constant 1023 and the LED always on) is wha t seems like a sine wave, oscillating between 0 to 1023.

Then quite simply you have not got the analogue pin connected to 5V that is referenced to the ground of the Arduino.
That means where ever the 5V came from it's ground is not connected to the Arduino ground.

If the 5V is from the Arduino itself then you have either not made the connection correctly or you have fried the input pin.

So SCHEMATIC like you were asked to provide.