Skip to main content
24 votes

Why am I receiving random input values in my Arduino?

You're getting noise pickup on the input pin when the button is not pressed. You need a pull-down resistor, about 10 kΩ to ground, to quiet the noise when the switch is open. Or even easier, use the ...
JRobert's user avatar
  • 15.3k
9 votes

Input Oscillating Wildly

Pins configured as INPUT are in a high impedance state and very sensitive to electrical noise from the environment, especially with wires connected to them See Arduino Tutorial Try using INPUT_PULLUP ...
Bra1n's user avatar
  • 1,008
6 votes
Accepted

digitalRead keeps giving 1

You have set Pin 2 to HIGH, which is 5V. You have set Pin 4 to INPUT_PULLUP, which means if no signal is driving it, it will be HIGH. You have connected a button between Pins 2 and 4. So, if you don'...
jose can u c's user avatar
  • 6,974
6 votes
Accepted

Can I use the PWM pins as regular digital input/output pins?

Yes you can use them as ordinary digital io pins. PWM is essentially a normal digital output pin that is repeatedly turned on and off at a high rate. The magic is that the turning off and on is done ...
GMc's user avatar
  • 393
5 votes
Accepted

Read int from Serial

.parseInt() reads incoming text up until either it times out or until it reads something that isn't a number. You are sending a number, and most likely a line-ending. If that line-ending is a simple \...
Majenko's user avatar
  • 105k
5 votes

How should I connect 5 buttons to arduino so that I can use the least number of inputs all the buttons are connected to ground

If all switches have one input grounded, you cannot use matrixing. In any case, the best you could do would be a 2 * 3 matrix, which uses 5 signals, the same as individual switching (though you may ...
user_1818839's user avatar
5 votes
Accepted

How to wire a three-pin on-off-on switch for reading input?

You talk about wiring a switch to control lights directly. Instead, you want to use your switch to send information to your Arduino. You link to an SPDT (single pole, double throw) switch. When ...
Duncan C's user avatar
  • 5,702
5 votes
Accepted

Unable to use analog pins as digital inputs

A6 and A7 are special on the nano. They are the only pins that can't be used for digital. They are only analog inputs.
Majenko's user avatar
  • 105k
5 votes
Accepted

Is it bad practice to multitask without timing constraints

Like often, the answer is: It depends. Generally it is non-blocking programming, when you do only short things on each loop. What exactly can be considered short depends on the situation, meaning, ...
chrisl's user avatar
  • 16.3k
4 votes
Accepted

How to detect if LED is switched on in external circuit using Arduino NANO?

I'm afraid your circuit does not work. In fact, the base of the transistor is always connected to the power, regardless the LED being ON or OFF. Therefore the BJT would be always in the ON-state. Also ...
next-hack's user avatar
  • 401
4 votes

just a silly doubt about glowing an LED

What will happen is you will damage your LED and/or your Arduino since you haven't mentioned a current-limiting resistor (220 ohms could well be suitable). However the general concept is perfectly ...
Nick Gammon's user avatar
  • 38.4k
4 votes

How to wire a three-pin on-off-on switch for reading input?

I suggest this simple circuit: simulate this circuit – Schematic created using CircuitLab Set both inputs to INPUT_PULLUP. If the input reads LOW, that means it has been grounded by the switch. ...
Edgar Bonet's user avatar
  • 43.3k
4 votes
Accepted

Multiple Push buttons to one input

Michel Keijzers pointed out the issues you have in your code. But then there is also an issue with your circuit: if you press any of the push buttons, the analog input pin gets connected to one of the ...
Edgar Bonet's user avatar
  • 43.3k
3 votes
Accepted

Intermittent LOW reading from input pin set to INPUT_PULLUP

My guess would be that you're getting noise interference on the line and it's too much for the Arduino's little internal pullup. Try adding an external pullup resistor - say 5k-10k (exact value is ...
Mark Smith's user avatar
  • 2,181
3 votes

just a silly doubt about glowing an LED

Yes it will, try it. This is one of the way to use a LED as a light sensor and light source by connecting it to two different Digital pins. Ref.: https://playground.arduino.cc/Learning/LEDSensor
MatsK's user avatar
  • 1,356
3 votes
Accepted

Why can I measure two pins simultaneously?

You can test it easily by calling the function twice directly after each other. If the first time a true is returned and the second time a false, the state is internally reset. But probably because ...
Michel Keijzers's user avatar
3 votes

Why can I measure two pins simultaneously?

https://github.com/thomasfredericks/Bounce2/wiki I'm not familiar with the Bounce(2) library, but looking at the above site, it looks like "fell" is more of an "instant" thing, where it isn't ...
computercarguy's user avatar
3 votes

Digital Inputs have gone crazy

Solved it, but here is the solution, so there is an answer available for anyone who might encounter the same problem... Quality check your protoboards. This is making me feel stupid. The protoboard ...
Gundesalf's user avatar
3 votes

digitalRead keeps giving 1

There are to simple options how to connect a simple button. You mixed them. Better option is connect the button between pin with INPUT_PULLUP and ground. The pin is HIGH when the button is open and ...
Juraj's user avatar
  • 18.1k
3 votes

4x4 matrix keypad - Multiple inputs cause extra readings

I have a post about keypad matrices which discusses this issue. The issue with keypads is, that if you don't install diodes, if three keys are pressed the current finds its way around those three keys ...
Nick Gammon's user avatar
  • 38.4k
3 votes
Accepted

Does a pin (input pin Arduino) still float when connected to GPIO on RPI?

You need to enable the internal pull-up resistors which are designed to prevent undefined input states on unconnected inputs. Change pinMode(5, INPUT); to pinMode(5, INPUT_PULLUP); For more ...
Transistor's user avatar
3 votes

Can Arduino accept HDMI input video stream, and output it without any modification to the video?

No. HDMI uses multiple serial data streams at gigabit rates. No Arduino is ever going to do that sort of thing. If you want something programmable to do that kind of thing you need an FPGA.
Majenko's user avatar
  • 105k
3 votes
Accepted

Longruner Nano ATMega 328P input stays HIGH for 1s longer than the reality

Don't use Vin as a logic source. Use the +5V pin. Also, disconnecting the pin is not the same as grounding it. It is "floating". For a proper test, connect a +5V to the pin, and follow it ...
Nick Gammon's user avatar
  • 38.4k
3 votes

Multiple Push buttons to one input

You made a few mistakes with the three lines, first one being: if (temp = 340) First, the single '=' is an assignment operator instead of a comparing operator. You want to use '=='. However, you ...
Michel Keijzers's user avatar
3 votes

Measure the time between 2 inputs

The way to go depends on the time range, that the event will have. The Arduino framework already includes a function for timekeeping: millis(). It returns the number of milliseconds since the startup (...
chrisl's user avatar
  • 16.3k
3 votes

Why am I receiving random input values in my Arduino?

Your code mentions pin 3 while you describe using pin 2. Perhaps that has to do with your error. Otherwise, check the following things: do you use long cables or is it near strong magnetic or static ...
TeD van Loon's user avatar
3 votes

Why am I receiving random input values in my Arduino?

Here is what you can do Check if the switch is connected to the defined input pin. The Arduino starts form pin 0 and sometimes we can misread while connecting. Check if the serial monitor has same ...
eToll Systems's user avatar
3 votes
Accepted

Using 1 ms delay() in a for loop to check inputs.. Bad?

You can do this, for quite simple sketches. It starts to become ugly if you add more features and conditions. Therefore, the "correctTM" (read: professional) way is to implement a state ...
the busybee's user avatar
  • 2,103
2 votes
Accepted

Can an arduino tell between being powered by USB or by the jack?

No, you can't do it without extra hardware. You need to pass VIN through a voltage divider so it sits within 0-5V when powered by 12V, then feed that into an ADC input. Protect the on-board voltage ...
Majenko's user avatar
  • 105k
2 votes
Accepted

Reading Multiple switch inputs

You could use a MCP23017 or similar. Its an IC that provides 16 IO ports via I2C, I think you can have 4 of them so that should be enough for both hands. Or you could use resistors. All the buttons ...
Code Gorilla's user avatar
  • 5,637

Only top scored, non community-wiki answers of a minimum length are eligible