I’m using an Arduino-uno
I'm trying to read an PWM signal being output by pin 6. I'm attempting to read it with pin A0.
5 volts are being supplied from pin 6 to a 300 ohm resister in series with one led. This circuit returns to the analog input pin A0.
It'll admit it's a strange set up and I was told to use a pass through filter to read the signal.
At this point I'm not concerned with whether the program reads the right values, so despite the code involving the serial monitor I'm just trying to figure out why the led won't turn on anymore.
As I stated in the sketch, this exact set up was working fine yesterday. The led was on and (accurate or not) there were consistent values being printed to the serial monitor.
I'm trying to figure out now what changed after I unplugged it last to create a now open circuit.
```
void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
// I also tried setting the A0 pin as an input even though I thought you didn't have to and it didn't change anything.
}
void loop() {
analogWrite(6, 255); // This pin is working as an output, I tested it to ground and led lights.
int value = analogRead(A0); // I realize inputs are typically used for things like potentiometers
// But just as an example the LED should still turn on when connected here, correct?
//And it did the first few times I did it... maybe that was the problem?
Serial.println(value); // This was all working previously. It just randomly stopped.
// Now this just prints random numbers and the circuit remains incomplete.
// Even if the input pins are not supposed to be used with 5 volts, Why was it working before then...
// ALSO it does not matter which pins you use for what...
// No current is running through the digital inputs with digital output set to HIGH.
// And No current runs through the analogInput pins when analogWrite is set to 255.
// Once again, I apologize if my terminology is off.
}
```
This is what I did to trouble shoot:
With the same sketch running on the board...
I connected a jumper from pin A0 to ground and the serial monitor switched from a bunch of random values to a solid 0. So it recognizes input still... in a sense.
Then I modified the sketch...
void setup() {
Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(8, INPUT);
}
void loop() {
// now I'm attempting to read a digital signal with the same circuit...
// Pin 6 is connected to a 300 ohm resistor in series with an led which returns to pin 8.
digitalWrite(6, HIGH);
int value = digitalRead(8);
Serial.println(value);
}
This gave the same result. The led wont turn on anymore unless the circuit ends are connected from a voltage source to ground.
Previously, any pins configured as INPUT would not only read consistent values but also complete the circuit, turning the led on.
Now the pins only recognize zero volts and do not complete any circuits. You can't even use a simple potentiometer if you wanted.
Each pin that can be configured as an INPUT acts the same way.
The only thing I did between the times when it was working and wasn't was unplug and plug in the board...