New user here. Using the examples provided on the Arduino IDE software I could produce melodies with a piezo buzzer, or have a blinking LED.
Not anymore. No digital pin is giving anything. I can see the embedded LED blink if I program the Pin 13, but no impact outside of it.
So I tried connecting an output digital pin (13) to an Analog input pin, or any one that can be put as input (A7, D5, etc.) (with a resistor so not to destroy the little thing).
const char out=13;
const char in=8;
char i=0;
void setup() {
Serial.begin(9600);
pinMode(out, OUTPUT);
pinMode(in, INPUT);
digitalWrite(out, LOW);
}
void loop() {
if(i&1){
digitalWrite(out,i&2?HIGH:LOW);
}else{
Serial.println(analogRead(in));
}
i++;
delay(50);
}
The output has been 0, whichever digital pin it is connected to.
How can I actually find out if, by any chance, I successfully (!) damaged all my digital pins?
- I currently use a breadboard
- The ground is connected correctly (to GND)
- It stopped working between uses, last time I was trying a
Tone(out,val)
melody - I'm measuring the out-pin value by connecting it to an analog in-pin with a resistor in series
- I did set the out-pin as such during setup. (
pinMode(out, OUTPUT);
)
So! Looks like I didn't understand the codes for the digital pins. I thought we had to use the pin number, but the digital pin number (say 10
for D10
) is what it takes to address it. And I was always referring myself back to the schematic for each pin -_-.
As well with the accepted answer, I needed to pull down (or up? still can't figure it out!) the input pin with a resistor to ground.
Thanks everyone!