Powering at 5 volts, atmega328 output ~4.7 volts. I need to output between 12 and 24 volts @ 2 amp. I'm currently using relay but they are costly. Is there a way to do it with transistors or any thing cheaper?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
As @Gerben said in the comments, I would also recommend an N-channel MOSFET. OnSemi has a great application note on how to determine what type of MOSFET you would need based on your given load requirements and how to use it as a switch. You can find that app note here.
The basic idea is to provide an enable signal from your atmega328 to the gate of the MOSFET to drive it into saturation or to turn it off. You would connect your 12/24V supply to the drain of the MOSFET and connect your load to the source of the MOSFET. The basic circuit can be seen in the application note.
Hope that helps!