bit()

설명

특정 비트(bit)의 값을 계산합니다(bit 0은 1, bit 1은 2, bit 2는 4, 등등).

문법

bit(n)

매개변수

  • n: 계산할 비트 값

반환값

  • 비트의 값.

예제 코드

void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps long x; for (int n = 0; n < 16; n++) { x = bit(n); // equivalent to x = 1 << n; Serial.println(x, BIN); } } void loop() { }

The result in Serial Monitor:

COM6
Send
1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

더보기

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.

※ OUR MESSAGES