1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(UNO)8ビット機で-1を作って遊ぶ。あと-3も

Last updated at Posted at 2024-08-21

● -1の作り方は、全ビット反転して+1する。

aを一時ワークとする

反転は、「~」

例 ~a

aに+1は、インクルドという、インクルドは、「++」

例 a++

処理を連続させる

例 a = ~a
a++

こんな感じ

a = ~1;
a++;

結果

o_coq337.jpg

プログラム



//mainasu_1_asobu_UNO_1

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println();
  Serial.println("START");
  Serial.println();
}

// the loop routine runs over and over again forever:
void loop() {
  
  char a,b;

  a = ~1;
  a++;

  b = ~3;
  b++;
  
  Serial.println((int)a);
  Serial.println((int)b);
  
  delay(3000);        // delay in between reads for stability
  
}

 
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?