What Are Snap Circuits?
(you may need to right-click and choose Download or Save Target As)
If you have not completed the introductory project please go to Snap Circuits - Introduction.
Using the Arduino, monitor a button, that when pressed, will launch the fan.
Building the Circuit
The minimum set requirement for this project is SC-300.
Build the following circuit:
Click the link below to download a PDF containing the circuit diagram and instructions to build it (the PDF file can also be found in the GitHub repository).
Here are images of the components that you will use to build the circuit.
Here are images of the completed circuit.
Loading the Sketch
The attachment below contain the sketch for this project. Click the link below and save this to your computer.
Download Arduino Sketch (you may need to right-click and choose Download or Save Target As)
Load this sketch into the Arduino IDE in the same manner as in the Blinking LED project. After it is loaded compile and run it. The sketch for this project will write output to the serial port so you will need to open the Serial Monitor from the Tools menu (you can press
This project is really two circuits in one. The first circuit monitors the push button and waits for it to be pressed. When the switch is opened, the Arduino pin D3 is connected to ground through the resistor R4. Reading the value of this pin will return the value
LOW. When the button is closed (pressed), the D3 pin is connected to 3V3 directly and the circuit between 3VS and ground is completed through the resistor R4. We use a high resistance of 10K here to limit the current flow. If we did not put a resistor here or we put a value too small we would short the Arduino power supply and cause the Arduino to shut down or restart.
The second circuit uses a relay to turn a motor connected to a battery on and off. The relay and battery are required because the Arduino cannot push enough current to run the motor on its own. The relay is a switch that is activated by current from another isolated circuit. The relay in this circuit is connected to an Arduino digital port that will activate and deactivate the relay. When the relay is activated, the circuit connecting the battery to the lamp is closed and the motor turns on. When the relay is deactivated the circuit is open and the motor turns off.
The software will monitor the value of pin D3. When the pin is low the software ignores it and does nothing. When the pin goes HIGH (the button is pressed) the software changes a flag to indicate the button was pushed and starts the motor. When the button is released, the pin goes LOW and the software turns off the motor. When the motor stops the fan will launch.
You may notice when you press the button the relay makes a clicking noise momentarily and then stops. This is due to the switch "bouncing" when you press it down. As the switch contacts close, they actually bounce a few times before finally making permanent contact. This results in the switch opening a closing a few times while being press making the relay open an close causing the clicking sound. To eliminate this effect, the circuit requires "de-bouncing". See the project De-bouncing a Switch for more information on how to do this.