Skip to main content

How to control RGB LED using Arduino Uno

RGB LED is the abbreviation of ‘’Red Green Blue Light Emitting Diode’’. RGB LED is the most amazing type of LED which has the ability to create millions of different shades of light colors using red, green, and blue colors.

How to operate push button with Arduino


Push buttons are the basic on-off switching buttons most commonly used in less to highly complex electronic devices. Push buttons are able to connect two points whenever they are pressed. Push-button acts as a manually operated control device. When the button is pressed that means the short circuit is achieved between two points. On the other side when the button is not pressed then the open circuit or no connection developed between the points.
In this article, I will explain to you all the basics about the push button. A push-button is a very simple control device but we can operate it with pull-up and pull-down resistors. I will explain to you how an LED can be operated using a push button with a pull-up and a pull-down resistor. I will also explain to you how a buzzer can be operated with the help of a push-button. All these examples will help you to understand all the basics about the push button.

The push-button has four legs but we can use only two of them because of their internal structure. We can connect the push button directly with the VCC or 5-volt power supply. After that when we press it then the software will read it as HIGH until we change the state and perform the operation. But when the button is released after that system will get confused and does not able to recognize what is connected in the input. As result, the software will read HIGH or LOW value non-uniformly and assume some noise in this condition, due to which unexpected output will be observed. To avoid this situation it is necessary to connect pull-up or pull-down resistors with the push button.

How to operate LED using a push button (with an internal pull-up resistor):

Arduino has internal pull-up resistors (which means the resistors are connected to power internally). If we do not want to connect an external pull-down resistor then we can use these internal resistors directly with the help of the INPUT_PULLUP argument in pinMode(). This connection effectively inverts the operation of the push button. In this example, as the button is not pressed then the LED will be in one state and as the button is pressed then the LED will be in the off state.

Required Component:

  • 1 x Arduino Uno board...............................BUY
  • 1 x LED.......................................................BUY
  • 1 x push button............................................BUY
  • Few jumper wires........................................BUY
  • 1 x 220-ohm resistor....................................BUY

Connection diagram:


Circuit Description:

According to the connection diagram, the one terminal of the pushbutton is connected to the 5-volt power supply and the other terminal is connected with pin 7 of the board and GND. The shorter leg of the LED is connected with the GND and the longer leg is connected with pin 8 along with the 220-ohm resistor.

Code link: Click here

Output:



How to operate LED by push button (with external pull-down resistor):

In this example, as the button is pressed only then the LED will be on and as the button is not pressed then the LED will be off. LED will be “ON” only for the duration for which the button is pressed otherwise it will be off.

Required Component:

  • 1 x Arduino Uno board
  • 1 x LED
  • 1 x push button
  • Few jumper wires
  • 1 x 220-ohm resistor
  • 1 x 1 K ohm resistor

Connection Diagram:


Circuit Description:

According to the connection diagram, one terminal of the switch is connected to digital pin 7 and the other pin is connected to the 5-volt power supply pin of the Arduino board. The one terminal of the 1 K ohm pull-down resistor is connected with the switch and the other terminal is connected with the GND. The shorter leg of the LED is connected with the GND and the longer leg is connected with the digital pin 8 along with the 220-ohm resistor.

Code Link: Click here

Output:


How to operate buzzer using a push-button with Arduino Uno:

In this example, a buzzer is operated with the help of the push button. As the button is pressed then the buzzer will generate sound and as the button is released then the buzzer will stop immediately. Therefore buzzer will operate only for the duration for which the pushbutton is pressed. I have used the external pull-down resistor along with the push button.

Required Component:

  • 1 x Arduino Uno board
  • 1 x buzzer
  • 1 x push button
  • Few jumper wires
  • 1 x 1 K ohm resistor

Connection Diagram:



Circuit Description:

A buzzer is a two-terminal (one is shorter leg and another one is longer leg) device. The longer leg of the buzzer is connected with pin 5 of the Arduino board. The shorter leg of the buzzer is connected with the GND terminal of the Arduino Uno board. As we know push button has a fore terminal and we can provide connection only on two of them because of their internal structure. One terminal of the pushbutton is connected with a 1 k ohm pull-down resistor and pin 8 of the Arduino board and another terminal is connected with the 5- volt power supply pin of the Arduino board.

Code Link: Click here


Output:






Comments

Popular posts from this blog

Smart Plant Watering System Using ARDUINO UNO

As we all know, plants play an important role in our life, there are countless benefits we get from plants but the most important is fresh air and the pleasant atmosphere on the earth. Hence,   It is not only our social duty as well as the responsibility that we should plant trees as much as we can and also take care of them. But  the biggest challenge we face, is, taking care of them,

How to use LCD with Arduino Uno

Liquid crystal Display 16x2 (LCD) is a widely used electronic device to establish communication between the real world and the electronics-based machine world.

How to operate soil moisture sensor with Arduino

The soil moisture sensor is the most amazing sensor used to measure the quantity of water present in the soil and defines the moisture level of the soil as the output. Because of its amazing operating principle, this sensor is used in applications such as automatic irrigation systems, agriculture research applications, landscape irrigation, indoor planting system, and lawns. I have also made an advanced level project  "Smart Plant Watering System" using a soil moisture sensor.

ad

ad