bitClear()

설명

숫자 변수의 한 비트를 지웁니다(그 자리에 0을 씀).

문법

bitClear(x, n)

매개변수

  • x: 비트를 지울 숫자 변수
  • n: 지울 비트의 위치, LSB(맨 오른쪽 비트)가 0, 왼쪽으로 갈수록 1씩 증가

반환값

  • 없음

예제 코드

Demonstrates the use of bitClear() by printing the value of a variable to the Serial Monitor before and after the use of bitClear().

void setup() { Serial.begin(9600); byte x = 0b10000100; // the 0b prefix indicates a binary constant Serial.print("BEFORE: "); Serial.println(x, BIN); // 10000100 bitClear(x, 2); // clear the third bit Serial.print("AFTER: "); Serial.println(x, BIN); // 10000000 } void loop() {}

The result in Serial Monitor:

COM6
Send
BEFORE: 10000100 AFTER: 10000000
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

더보기

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
  • Any suggestion, correction, and translation? please email us at ArduinoGetStarted@gmail.com, We appreciate it
  • We mainly keep improving the references in English. See English version of this page for the latest update.