티스토리 뷰

Ref: https://roboticsbackend.com/arduino-input_pullup-pinmode/

 

Arduino INPUT_PULLUP Explained (pinMode) - The Robotics Back-End

How to use Arduino INPUT_PULLUP with the pinMode function? Complete explanation with 3 different examples, with and without INPUT_PULLUP.

roboticsbackend.com

 

Code


const int BUTTON = 2;
int BUTTONstate = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(BUTTON, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  Serial.println(digitalRead(BUTTON));
  BUTTONstate = digitalRead(BUTTON);
  if (BUTTONstate == HIGH)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  } 
  else{
    digitalWrite(LED_BUILTIN, LOW);
  }
}

'IT' 카테고리의 다른 글

Use tab key in Power Automate  (0) 2023.10.20
Shortcut for Edge profile with custom icon  (1) 2023.10.16
Airtable Connector Support  (23) 2021.06.15
MS Certificates  (0) 2021.01.10
If I want to buy some gaming stuff  (0) 2020.12.16
댓글
Announcement
Recent Posts
Recent Comments
Total
Today
Yesterday
Link
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
Search by month