Those devices use opto-isolated inputs. To all intents and purposes they look just like an LED with a resistor in series.
The built-in resistor looks like it sets the current to "between 8mA and 15mA" and typically 10mA, though it's impossible to say what it actually is. So we'll take the worst-case scenario of 15mA.
The Arduino has an absolute ...
It would seem this library needs a single pin to communicate. So it
doesn't really matter whether the port you choose has only a few pins
available. Also, you do not care that some pins can have extra
functionality, like SPI, I2C, etc, unless you do plan to use that
There is one think you should be aware of: the library uses the in and
It's easy to confuse the pins of these single-pole buttons - I still do it. Only two pins are needed for this kind of button. The extra two are there for mechanical stability on the PC board.
Lay the button on one of its sides:
If the two upper pins come out of the top edge, those pins are switched - either open, or shorted by the button. Ditto, for the two ...
It's hard to tell which pins of the switch do what. Since you have your inputs set up as INPUT (instead of INPUT_PULLUP) you should have a resistor (10k Ω, say) tying those pins to ground. Then the other end of switch should connect to +5V. Don't connect the switches to both +5V and ground.
Use a multimeter on continuity to make sure that the pins of the ...
This should be in the documentation of the motor or encoder, and that is the first place to look.
If you don't have any documentation, here is my best guess:
ABZ suggests it is an incremental encoder with channel A and B for quadrature encoding (giving direction and speed), with Z as the index pulse for getting absolute position once every rotation. FG is ...
I can think of three distinct ways (and one that is similar to another) of doing what you want.
But first a note on polymorphism. The HardwareSerial class is itself a child of the Stream class. It's this Stream class that provides all the read/write functionality (it, itself, is a child of the Print class which provides all the print(...) functions).
If all ...
Your button needs a pulldown resistor to work reliably.
See the discussion and solution here
The resistor, with a value of around 10K (but any value between 3K and 20K will probably do), needs to be between the input pin or your Arduino and ground to give it a defined value when the button is released.
Putting a resistor between the Arduino pin and ground ...
What motor are you using? If it works straight from the 5v but not from a GPIO, it could be an issue of insufficient power.
As @StarCat4 mentioned, you also need to add a digitalRead inside your while loop if you want the motor to ever turn off.
After spending way too much time on the code, I figured that it had to do with something entirely different:
The RFID reader created an RF interference on the data wire towards the LED strip... Shielding it properly did the trick, no matter which pin is being used.
Thanks for the help anyway.