Button That Will Provide Power to Your Project for an Amount of Time and Then Turn Off Again

Introduction

Finished SparkFun timed power button

In this tutorial you will learn how to add together an on push button that will provide power to your project for an amount of time and then plough off again. Nosotros will exist using a Solid State Relay (SSR) to deal with AC (alternating current) voltages like what you would see coming out of your wall at your house.

Delight DON'T Hurt YOURSELF! When dealing with high voltages, and high currents, please be extra careful and have any and all precautions.

Required Materials

If you would similar to follow along with this tutorial, you will need the following:

Suggested Readings

Earlier getting started, you may find some of the concepts below helpful.

  • How to Solder
  • Voltage, Current, Resistance, and Ohm's Constabulary
  • How to Use a Multimeter
  • Alternating Current (Ac) vs. Direct Current (DC)
  • How to Ability a Project
  • Connector Basics
  • Electric Power
  • Controllable Ability Outlet

Why Have a Timed Power Button?

Saving energy is always a good thing, but some projects accept sensitive components that need a fleck of a break and would last much longer if they weren't on all the time.

Some interactive projects should not stay powered on indefinitely. Parts of LEDs (especially RGB LEDs) tin burn out, systems can lock up. In SparkFun'due south new retail space we have dozens of demos that could do good from a big button that allows the user to power up the project for 5 minutes then powers down until the next client walks by. The get-go project to become this attention is our classic Picture Frame Tetris. We detest leaving this on for 24 hours a day because it wastes power, information technology doesn't have a good screen saver mode, and we are worried that the LEDs may burn down out over fourth dimension. This button was designed for that, a simple way to provide ability to a projection for a short time, just when needed.

Getting Started and Uploading Code

Since the project to which I am adding a timer uses DC (direct current), I could accept easily added the timer to regulate the DC voltage using simply a simple DC relay switch. Most projects in your home volition exist running off power from the wall, so this tutorial will focus more on how to regulate the Air conditioning voltage and current.

We will start with uploading the lawmaking. For this project, I have chosen a 5V Pro Mini. To Plan a Pro Mini, you'll demand a 5V FTDI Breakout. If your system is using 3.3V instead of 5V, nosotros also accept a 3.3V Pro Mini, and 3.3V FTDI Breakout to match.

To connect the Pro Mini to the FTDI Breakout, all you need to do is solder some correct-angle male person headers onto the FTDI inputs on the Pro Mini.

Pro Mini with right-angle male headers for the FTDI breakout

Pro Mini with correct-angle male headers for the FTDI breakout

Once y'all have the FTDI breakout plugged into the Pro Mini, you can use a USB to Mini-B Cablevision to plug information technology right into your figurer.

Open up the Arduino IDE, and upload the example code to your Pro Mini (for specific info on what the code is doing take a await at the comments in the code):

          language:c  /*  SparkFun simple lawmaking for running an On timer  for power from a button push By: Sarah Al-Mutlaq  7/9/fifteen */  int startButton = 13; //pivot recieving info from start push int controlPin = 4;   //pin we will use to contol power   unsigned long timerCount = 0; // variable to hold our timer info   void setup() {   pinMode(startButton, INPUT); //set pin every bit recieving info   pinMode(controlPin, OUTPUT); //set pin equally giving info   digitalWrite(controlPin, Low); //starting the control to project power as off }  void loop() {   if (digitalRead(startButton) == HIGH)      { //if the start button has be pushed      timerCount = 5 * 60 * 10; //set timer to approximately v mins       //(v mins *  60 sec * 10 * i deciseconds)      //this is gear up to restart the timer whenever the showtime       //button is pushed      //not extremely exact since that is non what I needed for this project      //if you are looking for something more exact, wait into       //SimpleTimer() Arduino funtions and libraries:      //http://playground.arduino.cc/Lawmaking/SimpleTimer#F_restartTimer     }   if (timerCount != 0)    { //if the count down timer is still running      digitalWrite(controlPin, HIGH);       //tell the command pin to provide power to the project      timerCount = timerCount - 1;       //count down of a decisecond (0.1 sec)      delay(100);       //delay for timercCount refrence of a decisecond    }     else { //if the timer has run out      digitalWrite(controlPin, Low);      //tell the control pivot to stop power to the project    } }                  

Hardware Hookup

As y'all can encounter in the lawmaking, we will exist hooking up the button to pin xiii of the Pro Mini (this can be inverse to any pivot in the code) and pivot 4, as well as 5V loftier and Ground to our SSR kit (likewise can be changed in the code). To connect the Pro Mini, you can either directly solder wires onto the pins, 5V, and ground. Or, y'all can solder on female headers, and plug wires into those.

Photo of Pro Mini Arduino with headers

Photo of Pro Mini Arduino with headers

Fritzing diagram of button Pro Mini and SSR kit hooked up

Fritzing diagram of push button, Pro Mini, and SSR kit hooked up

The SSR kit does not come with all of its parts soldered on, so yous volition need to assemble it.

SparkFun Solid state relay kit all hooked up

Solid land relay kit all hooked up

This solid state relay kit is rated for a max of 125VAC at 8A, and so, for a small-medium size projection, this is a fine option. Still if your project is going to be pulling more current or voltage you might want to look into a total blown Solid Land Relay (SSR), this one tin handle 380VAC and 40A!

Warning! That is a lot of electric current then please, be extra extra conscientious with those kind of projects.

Since I used a Big Dome Pushbutton, I will as well be hooking up the LED inside to Vcc and Ground. The code recognizes that the push button is pushed when the pin goes loftier. This means the push will be pulled low and only get high when the push is pushed (significant 5V will be continued to the pin the button connects when it is pushed).

Terminal, the load pins on the SSR kit volition be hooked upward to 1 of the wires that are going from your project to the AC ability supply (usually the wall).

Photo of SparkFun SSR kit hooked up to an AC to DC power supply

Photo of SparkFun SSR kit hooked up to an Ac to DC power supply

To protect the projection and brand sure that nothing is going to short, I recommend covering everything with electrical tape or Heat Compress. I also added a fair amount of hot mucilage to this project to protect all the connections and keep everything in identify.

Once everything is hooked up and in identify, yous can plug your Pro Mini (through the FTDI Breakout) into the wall with a 5V adapter, plug in your connected projection, and in that location y'all take it! A timed on button for your project!

I cut a few pieces of plywood and glued them together to form a fiddling housing for the push button.

Finished timer button in enclosure

Resources and Going Further

Ready for your adjacent project? Check out some of our other awesome tutorials:

DIY Light-Up Shoes

This tutorial provides everything yous need to know to brand your own low-cal upward high top sneakers!

GPS Geo-Mapping at the Push of a Button

Allow's ramp upward our GPS tracking skills with KML files and Google Earth. We'll brand a tracker that logs location and allows u.s.a. to visualize our steps with Google Earth.

allmonpentor.blogspot.com

Source: https://learn.sparkfun.com/tutorials/adding-a-timed-button-to-a-project/all

0 Response to "Button That Will Provide Power to Your Project for an Amount of Time and Then Turn Off Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel