Read a Pushbutton CloudX
A pushbutton is an electronic component that connects to points in a circuit when being pressed. It is a simple toggle switch used to control a device or machine. They also have a very wide application in electronics and we come across in our everyday life on almost all appliances or gadgets we use in the house.
The button pressed detection can be designed in two forms namely; Pull-up or Pull-down. When the pushbutton is open (not pressed) there is no connection between the two legs of the pushbutton, so one of the pin is connected to GND through a pull-down resistor of 10k ohms while its second pin is connected to 5 volts, this method is called pull-down. Following the diagram below, the cloudx microcontroller keeps on checking when a 5v is detected on P1 before it takes actions.
When one leg of a pushbutton is connected to GND and the second leg(same connected to a microcontroller pin) is connected through resistor 10k ohms to 5v, Hence checking for LOW on the microcontroller pin, this method is called a Pull-up design.
In this quick tutorial, we will use a pushbutton to turn on an LED and delay for a second when pressed.
if(digitalRead(1) is HIGH)
pin2 = HIGH;
pin2 = LOW;