0Pricing
Arduino & IoT Academy · レッスン

pinMode と OUTPUT

LED に電流を流すピンであることを指定します

「pinMode と OUTPUT」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Pins Have a Job

Every Arduino pin can either listen or speak. Before you use one, you must tell it which job to do. That setup is the role of pinMode. 🔌

Why OUTPUT Mode

To light an LED, the pin must send current out into the world. You declare that intent by setting the pin to OUTPUT mode.

The pinMode Call

You configure a pin once, inside setup(). The pinMode function takes a pin number and a mode, and it remembers your choice.

pinMode(13, OUTPUT);

Naming Your Pin

Hard-coded numbers get confusing fast. Give the pin a clear name with a constant so your sketch reads like plain language.

const int ledPin = 13;

Set It Up Once

You only need to declare a pin's mode a single time. Put pinMode in setup(), which runs once when the board powers on.

void setup() {
  pinMode(ledPin, OUTPUT);
}

The Onboard LED

Pin 13 is special: most Arduino boards wire it to a tiny onboard LED. That means you can test output with no extra parts. 💡

A Friendlier Alias

You do not have to memorize the number. Arduino gives you the built-in name LED_BUILTIN, which points to that onboard LED for you.

pinMode(LED_BUILTIN, OUTPUT);

OUTPUT vs INPUT

Each pin defaults to listening. Setting OUTPUT flips it so the pin actively drives a voltage instead of just sensing one.

What 'Drive' Means

An OUTPUT pin can push out about 5 volts or pull down to 0. That controlled push is how a pin drives an LED on or off.

Forgetting pinMode

Skip pinMode and your LED may stay dim or dead. The pin never enters OUTPUT mode, so it cannot push enough current to shine.

Setup Is the Stage

Think of setup() as preparing the stage before the show. Declaring your pin's mode here gets everything ready for the loop that follows.

Quick Check

You want a pin to light an LED. What do you call first?

Recap

You learned to claim a pin with pinMode and OUTPUT inside setup(). With the pin ready to drive current, you can now make it blink. 🎉

よくある質問

「pinMode と OUTPUT」レッスンは無料ですか?

はい。「pinMode と OUTPUT」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。

「pinMode と OUTPUT」で何を学びますか?

LED に電流を流すピンであることを指定します ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Arduino & IoT Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「pinMode と OUTPUT」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このArduino & IoT Academyレッスンでコードを書いて実行できますか?

はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. pinMode と OUTPUT
  2. digitalWrite の HIGH と LOW
  3. delay() と点滅のタイミング
  4. 外付け LED を安全に配線する
← Arduino & IoT Academyに戻る