Arduino is an open up source and become famous in very short time, due to its powerful features and simplicity. Arduino comes as boon for inventor, creative person etc. One can make their own system without having much noesis about core electronics and assembly programming.

In this commodity yous will learn how to pause the lawmaking and resume using a push push switch. Quondam, we desire our code to run only when user do some activeness similar to press switch of go some value of sensor. Few years back while making game loonshit for manual battel bot, I had used two switches for two team whether they are ready to start lucifer or not. When one team press the switch indicating they are gear up, the program volition wait for some other team to press the switch. When both the team go ready the timer for 3 minutes will commencement with beep sound. In the tutorial "" y'all will learn how to pause the program and resume just when i printing the button without using delay function. We cannot employ filibuster function where program have to resume afterward user interaction.

Pause and Resume Arduino Program using Switch author prototype

Figure 2: Author Prototype of Pause and Resume Arduino Program using Switch

Annotation: For demo purpose we are using 16×ii alphanumeric LCD.

Components Required Pause and Resume Arduino Program using Switch

Arduino nano x one

Push Push button Switch x 2

10k resistor x ii

sixteen×two LCD x 1

10K Variable resistor x ane

330E resistor ten 1

Circuit Description of Pause and Resume Arduino Program using Switch

The circuit of "" is shown in effigy 1, it is built effectually arduino Nano, ii button switches, an LCD and few other electronic passive components like resistor. LCD is used here only for demo purpose. If you have any confusing about interfacing LCD with arduino then please do watch interfacing video posted in youtube.

Ii switches with pulldown resistor is connected to arduino nano analog pin A0 and A1 every bit shown in circuit diagram. Two pulldown resistors are also used hither in order to overcome the transient response of switch. These switches are configured in high level trigger considering one terminate of both switches is connected to +5V power supply.

circuit diagram of Pause and Resume Arduino Program using Switch

Software Code:

Software lawmaking is written in arduino programming and compiled using arduino IDE. Let's see the code. For explanation nosotros are going to separate the code in diverse small section.

Defining the pin of button and LCD used in the project. If you connect the LCD as show in circuit, you practice not have to change it but if you modify your connection yous also have to alter the pivot definition.

In setup role we will ascertain the property of button switch i.east. whether we use it as input or output. Similarly, nosotros also begin the LCD.

Loop function run repeatedly, when loop part run, information technology calls button function and returns to loop office merely when push is pressed.

CheckButton() function check whether the push i is pressed or non. When button is pressed, the value become high for CheckButtonPress1 and render back to loop role.

Consummate Software Code