FrontPage

How Does This Work?

その仕組みは?

We have introduced two new concepts with this example program:

今回のプログラム例では、2つの新しいコンセプトを紹介しました。

functions that return the result of their work, and the if statement.

作業の結果を返す関数や、if文などです。

The if statement is possibly the most important instruction in a programming language, because it allows a computer (and remember, the Arduino is a small computer) to make decisions.

if文は、コンピュータ(Arduinoは小さなコンピュータです)に意思決定をさせるためのもので、プログラミング言語の中で最も重要な命令と言えるでしょう。

After the if keyword, you have to write a “question” inside parentheses, and if the “answer”, or result, is true, the first block of code will be executed;

ifキーワードの後、括弧の中に「質問」を書き、「答え」つまり結果が真であれば、最初のコードブロックが実行されます。

otherwise, the block of code after else will be executed.

そうでなければ、else以降のコードブロックが実行されます。

Notice that the == symbol is very different from the = symbol.

==記号と=記号は大きく異なることに注意してください。

The former is used when two entities are compared, and returns 44 Getting Started with Arduino true or false;

前者は、2つのエンティティを比較するときに使用され返します。

the latter assigns a value to a constant or a variable.

後者は、定数や変数に値を割り当てるものです。

Make sure that you use the correct one, because it is very easy to make that mistake and use just =, in which case your program will never work.

正しいものを使うようにしてください。間違いやすいのは、=だけを使ってしまうことです。

We know, because after years of programming, we still make that mistake.

何年もプログラミングを続けていると、いまだにそのようなミスをしてしまうからです。

It’s important to realise that the switch is not connected directly to the LED.

ここで重要なのは、スイッチがLEDに直接接続されているわけではないということです。

Your Arduino sketch inspects the switch, and then makes a decision as to whether to turn the LED on or off.

Arduinoスケッチは、スイッチを検査し、LEDを点灯させるかどうかの判断を行います。

The connection between the switch and the LED is really happening in your sketch.

スイッチとLEDの接続は、スケッチの中で実際に行われています。

Holding your finger on the button for as long as you need light is not practical.

光が必要な間、ボタンに指を置いておくのは現実的ではありません。

Although it would make you think about how much energy you’re wasting when you walk away from a lamp that you left on, we need to figure out how to make the on button “stick”.

点けっぱなしのランプから離れるときに、どれだけのエネルギーを無駄にしているかを考えさせられますが、オンボタンを「定着」させる方法を考えなければなりません。

トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-11-02 (火) 09:15:37