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!
-
1Welcome! Could you add a little more information about your setup. Do you use a breadboard? Do you have GND correctly connected to your external components? When did it stop working? How are you measuring the pin’s output? Did you set the pins to OUTPUT in setup()?StarCat– StarCat07/07/2020 06:27:12Commented Jul 7, 2020 at 6:27
-
Thank you StarCat! I have added the information thank you!B7th– B7th07/07/2020 06:55:41Commented Jul 7, 2020 at 6:55
-
1Do you have a multimeter available to measure the voltage on the output pins and the supply voltage? Is the Nano behaving normally otherwise?StarCat– StarCat07/07/2020 08:03:22Commented Jul 7, 2020 at 8:03
-
3A6 and A7 are analogue inputs only. They can't do digital reading or writing.Majenko– Majenko07/07/2020 08:21:09Commented Jul 7, 2020 at 8:21
-
1Did you set the pins to OUTPUT? Show the whole code.Delta_G– Delta_G07/08/2020 03:35:11Commented Jul 8, 2020 at 3:35
1 Answer 1
Your sketch works on a Nano (clone) that I have
I am using a high-brightness white LED with a 10kΩ resistor to bring the brightness down to a bearable level, so the current drawn is about (5v-2.2v)/10kΩ = 0.28mA. This is a low level of current and should be safe for poking around with.
I can see the embedded LED blink if I program the Pin 13, but no impact outside of it.
That suggests that the ATmega328P is essentially undamaged and that at least the IC leg connected to D13 is working as it should.
How can I actually find out if, by any chance, I successfully (!) damaged all my digital pins?
Without a multimeter or other tools, I would take a LED and resistor that draw less than 5mA, test them between VCC and GND to make sure they work
Then I would use the resistor and LED to check the output of each of the D2 to D13 outputs using your existing sketch.
When the onboard LED blinks, I am able to attach a LED and series resistor to pin D13 and get it to blink.
I wasn't sure what you intended by setting in
to 8
so I later changed your program as follows:
const char in=A1;
and I got this output on the serial monitor after connecting a jump lead from D13 to A1
0
1010
0
1009
0
1009
0
1009
0
1009
0
1009
0
1009
0
1009
0
1008
If I pivot the LED away from pin D13, I can use a jump lead as a test probe
Main points:
- pick a high resistor value that minimises current drawn but is still easily visible.
- check the LED works! (is right way around etc)
- use a jump lead as a probe.
There are more sophisticated test circuits you could build with a FET etc but this would normally be enough for me to decide if an Arduino's outputs are damaged.
Extract from ATmega328 datasheet - note the max current draw per pin is 40mA. Exceeding that is probably the easiest way to damage the IC but if the onboard LED labelled "L" (and connected to D13) works, it means that part of the IC is undamaged.
-
I'm impressed by how nice people already are, thank you! That is an exhaustive answer and shows you spent actual time to solve my issue. I'll test it and let you know what's the results!!B7th– B7th07/09/2020 01:48:49Commented Jul 9, 2020 at 1:48
Explore related questions
See similar questions with these tags.