Some questions I have about hardware

I’ve done this before for software, but now it’s time for hardware as I’m building my own thing :flushed: :wink:

  1. Can SPI pins be infinitely used? Like for example, if a board has only 4 SPI pins (so like 1 SPI component), and I connect a screen to them, can those 4 pins be re-used for another SPI component/module? Wondering 'cause the ESP32 only has like 4 SPI pins.

  1. What’s the difference between analogue pins and digital pins and PWM pins?

  2. What’s the difference between VIN and 3.3V/5V?

  3. Can I2C pins also be re-used if they’re already in use by something? Like the first question, but I2C.

You can put multiple components on an SPI bus but each must have its own separate Chip Select (CS) pin. So, in addition the common MISO, MOSI, SCK (and power and GND) pins, you need an additional digital output pin for each connected device.

Digital pins can only be set high or low (although they may have additional functions when used with built-in peripherals).

Analog and PWM pins are (usually) the same thing. In addition to being able to be used as digital pins, they can output a variable (analog) voltage. They do this by Pulse Width Modulation (PWM) that is controlled by an internal counter/timer, the PWM output of which must be filtered to provide a constant output voltage.

Digital pins can also do PWM through sofware “bit banging” but this uses CPU cycles.

VIN is usually a raw, unregulated power input that receives a voltage higher than the board uses to operate. An on-board voltage regulator takes this voltage and converts it to the regulated voltage (usually 5V or 3.3V) that the board uses.

3.3V and 5V pins can be either inputs or outputs, or both. If they are an input, they usually bypass the on-board regulator on VIN and must be supplied with a regulated voltage to power board. If they are an output, they will provide a regulated voltage that you can use to power off-board circuitry (within the output current capability).

Yes. I²C is a bus that many devices can be attached to. Each device has (must have) a unique address used to select it, so (unlike SPI) no additional pins are required. However, I²C is generally slower than SPI.


I’m assuming SS is CS? I know there isn’t a set name for the SPI stuff, though.

According to this website, you can make your own CS pins?

I found this too

So digital pins would probably be used for like buttons, and analogue pins would be used for like a potentiometer?

SS is “Slave Select”, which is “Chip Select” if the board is acting as a SPI slave instead of a master. If the board is acting as a SPI master, then SS can be used as a GPIO pin, including as a CS for a SPI slave device.

Any digital output pin can be used as a SPI CS pin.

Yes. A digital input could be used to read a button. A digital output could be used as a SPI CS.

Yes, an analogue input pin could be used to read the variable voltage output from a potentiometer, such as one in an analogue joystick. An analogue output could be used to light an LED at various brightnesses.


Could the CS pin on the SPI component/module theoretically just be connected to GND? I think it might be fine for a display because it uses the RES pin to reset.

Only if it is the only slave device attached to the bus. If there is more than one device then you can’t connect CS to GND on any of them because you have to be able to unselect a device in order to allow any other device to communicate.

If there are only two devices, then it’s possible to use a single output pin and an external inverter to select one or the other. That inverter could be just a transistor and a resistor or two.