Never touched a Raspberry Pi before.
I’m creating a simple puzzle box. It will need to be battery operated. There will be four buttons. When, and only when, all four buttons are pressed I want an electromagnet to activate. The magnet will push up a magnet on top of it in a tube.
What do I need to make this?
Sounds like you don’t even need a Pi for that. Just run a battery running through 4 buttons and an electromagnet, plus whatever resistor of whatever you might need to manage current.
I’m not much of an electrical guy, but the logic is plenty simple at least.
I have no idea how to do that. But I can write software, so using a Pi would be ideal.
You’ll need to wire it up either way, so I would suggest doing it without the Pi honestly. Adding a Pi to the equation is just making it more complex for no reason at all, unless the goal is strictly to learn how to use the Pi.
Like, the circuit “diagram” would just be something like:
Battery (pos) -> button 1 -> button 2 -> button 3 -> button 4 -> resistor -> electromagnet -> Battery (neg)
(Though actually, it could be in any order tbh)The only difficult part would be figuring out which resistor to use, but you’ll need to do that whether a Pi is involved or not.
The only justification of using a raspberry pi is if they want to make the box with a whole bunch of buttons and be able to dynamically set which 4 buttons open the box.
I’m late to the party on this, but I would agree with the others that Raspberry Pi is not only overkill, but will make this more difficult than it needs to be.
It’s a great job for a basic microcontroller, and the code needed for that will be simpler. You just need something like an Arduino, some wire, a few resistors and 4 buttons. Look at any intro to Arduino introduction that gets to button presses (and debouncing). Here’s a good guide from the start: https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-1/introduction
If you want to follow a guide end to end and can customize the code, this might be a helpful starting point with a very compact board: https://learn.adafruit.com/arcade-button-control-box/overview