What is High and Low in Arduino: Simple Explanation and Example
HIGH means a pin is set to 5 volts (or 3.3 volts depending on the board), representing an ON state, while LOW means the pin is set to 0 volts, representing an OFF state. These terms control digital pins to turn devices like LEDs on or off.How It Works
Think of Arduino pins like light switches in your home. When you flip a switch ON, electricity flows and the light turns on; this is like setting a pin to HIGH. When you flip the switch OFF, no electricity flows and the light goes off; this is like setting a pin to LOW.
In Arduino, digital pins can only be in two states: HIGH or LOW. Setting a pin to HIGH sends voltage (usually 5V or 3.3V) to that pin, which can power devices like LEDs or motors. Setting it to LOW means no voltage (0V), so the device is off.
This simple ON/OFF control is the foundation for many Arduino projects, letting you control lights, buzzers, and other components easily.
Example
This example turns an LED on and off every second using HIGH and LOW.
const int ledPin = 13; // Built-in LED pin on most Arduino boards void setup() { pinMode(ledPin, OUTPUT); // Set the LED pin as output } void loop() { digitalWrite(ledPin, HIGH); // Turn the LED on delay(1000); // Wait for 1 second digitalWrite(ledPin, LOW); // Turn the LED off delay(1000); // Wait for 1 second }
When to Use
Use HIGH and LOW when you want to control devices that have simple ON/OFF states, like LEDs, buzzers, or relays. For example, turning a light on when a button is pressed or activating a motor only when needed.
This is useful in projects like night lights, alarms, or simple robots where you need to switch things on and off easily.
Key Points
- HIGH means the pin outputs voltage (ON).
- LOW means the pin outputs no voltage (OFF).
- Used to control digital devices simply.
- Works like a switch to turn things on or off.
- Essential for basic Arduino projects.