Input Pullup Serial using Arduino




This example demonstrates the use of INPUT_PULLUP with pinMode(). It monitors the state of a switch by establishingserial communication between your Arduino and your computer over USB.

Input Pullup Serial using Arduino




Additionally, when the input is HIGH, the onboard LED attached to pin 13 will turn on; when LOW, the LED will turn off.

Circuit

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Connect two wires to the Arduino board. The black wire connects ground to one leg of the pushbutton. The second wire goes from digital pin 2 to the other leg of the pushbutton.

Pushbuttons or switches connect two points in a circuit when you press them. When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton. Because the internal pull-up on pin 2 is active and connected to 5V, we read HIGH when the button is open. When the button is closed, the Arduino reads LOW because a connection to ground is completed.

Schematic

Input Pullup Serial using Arduino Schematic

Code

In the program below, the very first thing that you do will in the setup function is to begin serial communications, at 9600 bits of data per second, between your Arduino and your computer with the line:

Serial.begin(9600);

Next, initialize digital pin 2 as an input with the internal pull-up resistor enabled:

pinMode(2,INPUT_PULLUP);

The following line make pin 13, with the onboard LED, an output :

pinMode(13, OUTPUT);

 

For more detail: Input Pullup Serial using Arduino




This Post / Project can also be found using search terms:

  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1840 pAq_IqHA16-QikXw5zOcqb8yIq2HJOMimYrfQHu50WMiBi9GAx5AT4BB8nsqWor- 08dd51ba90fe5d839d2218ba450d6960264a3230&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1822 xlHxR0t_q-X1o5k48G115XtgQIJdR9yZrElB3mhxmkeSIuMa6ne8iW61KdGqEC4C cda4d9cb691d95d32c2d812643b0fc9d0880b0b6&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1823 k7Wrbph5qn4PJpyTylMG3Tfgj-PkickL6SAlokHDS_teliocX7T9mDZ1ksBalrld 20c82eac81a4a9262b39f2db38b680534a246c0b&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme
  • https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1838 8AsfzgMxGFo2n70N8r8_-vNIfIoe5R7EMDwioVI-XmrpMDU00fdZ3NqE9pZaYORa 7f5813669aefe1607855feae4066cdec9cce13a6&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme

Leave a Comment

*
= 4 + 5

(Spamcheck Enabled)

Read previous post:
Self Sufficient Arduino Board
Self Sufficient Arduino Board

This is a self sufficient Arduino board, which is powered by harnessing solar power and using a 9V rechargeable battery....

Close
Scroll to top