Good afternoon, I have an arduino leonardo, which until yesterday worked perfectly, it turns out that today I intend to use it for a keyboard emulator project and start pressing all the keys at the time I checked the entries and they are checking HIGH when I do not send them any signal , so it is impossible for me to use pulsadorews and any type of digital inputs, analog inputs dial 160 without sending any signal, when I put the digital pins as output works visually correctly. Help ! Tell me if I'll have to buy another Arduino or I can fix it in some way.
Hi there!
With digital pins, there are three states: LOW, HIGH, and something called high-impedance, which is when the pin is just floating and not touching any specific voltage.
For your project, it sounds like there are some pull-up resistors that bring the pins to a HIGH state even when no input is being put in. Are there any wires hooked up to the pins on your Arduino? If so, please try to unplug them all and try to run the following code:
void setup()
{
Serial.begin(9600);
for(int i = 0; i < 14; i++)
{
pinMode(i, INPUT);
}
}
void loop()
{
for(int k = 0; k < 14; k++)
{
Serial.print(k);
Serial.print("\t");
Serial.println(digitalRead(k));
delay(100);
}
}
Open up the serial monitor with your Leonardo plugged in and see what appears. If you could, post a picture of the results here in the forum so I can see.
Thanks
Best regards, Thanks for answering me. I have done the described test and this is the result of the serial monitor:
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 1
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 1
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 1
8 0
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
2 0
3 0
4 1
5 1
6 0
7 1
8 0
9 1
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 1
5 1
6 0
7 1
8 0
9 1
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
5 1
6 0
7 1
8 0
9 0
10 0
11 0
12 0
13 1
0 0
1 0
2 0
3 0
4 0
It seems that the high and low state were random.
By the way, I do not have any cables connected to the arduino.
That is exactly as expected then!
As noted above, when a pin is high impedance (ie, set INPUT), and not connected to anything, the pin will float, and the pin will pick up noise from the environment and transition randomly - the values measured from a floating pin are meaningless.
When you use a carefully designed wire on the floating pin to pick up a certain frequency of electromagnetic radiation, that's called an antenna.
OH !! true! A thousand apologies for occupying your time with this post. The problem was that the pull-down resistor of my project was not well connected, I thought that when the arduino sent signals like this it was a question of some error. But a thousand thanks for your help, now I know.