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.
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);
}
// 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.
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.