How do I step down 9V to 5V

I'm making a complex circuit on Arduino using a bunch of different components. One portion of the circuit is a switch that I want to detect on the Arduino. As I now understand, this means I need to use 5v as the signal.

Given that I only have a 9v battery hookup (and a 3.5 v AAx2 hookup) is there any way I can do this using resistors?

Show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

A digital HIGH voltage > 5v can be reduced using a resistor voltage divider.

An analog voltage to an analog pin can also be conditioned prior to connecting the Arduino using a similar resistor divider.

Google voltage divider Arduino

1 Like

why not use the internal pull up and switch to ground, works if the wires are not to long. A 9V battery is a bad choice for powering an Arduino especially if motors or more then a few LEDs are used however using it to supply Vin will work OK. Try to get a 10V - 12V brick and power via Vin but remember the Arduino a power supply it is NOT! You will have to determine what current you will need and power accordingly.