r/ComputerEngineering • u/ColoredRunes • 37m ago
Beginner with hardware-please help
Hi everyone, so I am an intermediate level developer who has developed several different kinds of applications and deployed websites, etc. I am wanting to now do some C programming on some hardware, but I honestly don’t really know where to start with this particular project. I have some LEDs that I’m going to be wiring up and I’ve already built the entire program that will deploy the iterations of different animations onto the development board but when it comes to the hardware, I have no idea what I’m doing. My first task is to simply connect this button to the ESP 32 so that I can get some understanding of how it works just in general and from there, I will move over to doing some more looking into the LEDs considering that they need a separate power supply that is going to be another deal that I am not sure what to do with.
TLDR: if you have hardware experience, please help me wire this simple project. I want to connect a button to an SP 32 and make it to something like turn the light on or off or print.
1
u/johndcochran 29m ago edited 7m ago
The button looks like a simple keyboard switch. But, having 4 wires instead of 2 is a bit surprising. Do you happen to have a link to the datasheet?
I am going to assume that you have a momentary contact SPST switch with an internal LED to light it. Before you do anything else, you need to identify what those 4 wires are. I assume you have a 5V power supply, and a resistor in the range of 470 to 1000 ohms.
So, let's first identify the wires for the LED. it may take as many as 12 attempts to identify which 2 wires, and the polarity.
Connect one of the 4 wires to ground via the resistor. Then touch, one at a time, the remaining three wires to +5V. The resistor should limit the current to a low enough value to prevent damaging anything. If they keycap lights up, take note of which wire was connected to ground and which to +5V. If nothing lights up, try again, using another wire connected to ground. It may take up to 12 total attempts.
After you've identified the pair of wires for the LED, the other 2 wires should be for the switch itself. Test it by connecting the +5V to one of switch wires. Connect the other switch wire to the wire for the LED that needs +5V. And connect the other LED wire to the resistor, and finally the resistor to ground. You should be able to make the LED turn on and off by simply pressing the button. If you can do that, they you've identified all 4 wires for your switch.
1
u/Ill_Engineering_9625 11m ago
First use a multimeter to determine which contacts are connected when you push the button, then you want to wire it to an input on the ESP32 so that pressing the button connects a pin to either high (3.3V) or low (GND). Then you want to add a pull up or pull down resistor (10k) to hold the pin in the other state until you press the button. Then you should be able to read the state in software, and you might have to apply debouncing to get it working reliably, basically only accept the button press when the value has stabilized for a few milliseconds.
1
u/brotherterry2 23m ago
When I took embedded systems a couple quarters ago, we used free rtos. They have extensive documentation that will allow you to get your project done. That, along with reading the data sheet and watching some tutorials on you tube will help you get it done. Also, if you dont know how breadboards are connected, look that up. Good luck :)