1. Home
  2. Explore
  3. Engineering
  4. Arduino Basics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Arduino Basics

Arduino and Microcontroller Study Notes

What an Arduino-Based System Does

An Arduino project combines electronic parts so that a device can sense information, process it, and respond. This same basic pattern appears in robots, household appliances, calculators, phones, and many other electronic systems.

A useful analogy is the human body:

  • Inputs are like the eyes and ears: they detect information from the environment.

  • The microcontroller is like the brain: it processes information and decides what to do.

  • Outputs are like muscles: they act on the world.

  • Wires are like the nervous system: they carry signals between components.

For example, a light sensor can detect that a room has become dark. The microcontroller reads that information and can respond by turning on an LED. A more complex device may use several sensors and motors to aim, move, or activate a mechanism.

A circuit alone may not seem very interesting, but combining electronics with mechanical parts can produce useful or entertaining machines. The same control system can be adapted to make a nightlight, an automated dispenser, a movable mechanism, or an alarm.

The central pattern in an electronic project is input → processing → output.


The Main Parts of an Electronic Project

Inputs: Sensors and Controls

An input provides information to the system. Inputs include sensors that measure the environment and controls that a person operates.

Examples include:

  • Light sensor: Detects the level of light.

  • Button: Detects a press or release.

  • Microphone: Detects sound.

  • Proximity sensor: Detects whether an object is nearby.

  • Knob: Provides a continuously adjustable control value.

  • Joystick: Provides directional control.

  • Soil-moisture sensor: Measures how damp or dry soil is.

  • Thermometer or temperature sensor: Measures temperature.

Inputs function like a device’s senses. They provide the information that the controller uses to choose what happens next.

The Brain: Microcontroller

A microcontroller is a small computer designed to control electronic devices. It reads input signals, executes instructions stored in its program, and sends signals to outputs.

The program determines how the microcontroller interprets each input. For example, one program might use a microphone to recognize a particular sequence of knocks; another might use a soil-moisture sensor to detect when a plant needs water.

Outputs: Actuators and Indicators

An output is a component that carries out the controller’s decision. Outputs may create movement, light, or sound.

Examples include:

  • Servo motor: Moves to a controlled position, making it useful for rotating or positioning a mechanism.

  • DC motor: Spins continuously when powered; it can drive a fan or wheel.

  • LED: Produces light.

  • Buzzer or speaker: Produces sound.

  • Other actuators: Mechanisms that physically move or affect the environment.

Outputs are sometimes called effectors because they cause an effect in the world, much like muscles do in a body.

Wires and Power

Wires connect components and provide paths for electrical power and signals. The human-body analogy treats them like a nervous system, but wires also form the conductive paths that let current flow through a circuit.

A battery or other power source supplies the energy needed to run the system. The basic input–processor–output model describes the system’s functional parts; a working build also needs power and electrical connections.


Combining Inputs and Outputs

The creative possibilities come from choosing how an input should control an output. The components themselves may be simple; the program and the purpose given to the device determine what it does.

Examples include:

  • A soil-moisture sensor could trigger an LED when soil becomes dry. A more elaborate system could send a message asking for water.

  • A microphone could listen for a particular sequence of knocks. If the sequence is correct, the microcontroller could activate a servo that unlocks a box.

  • A knob could control the speed of a fan or the position of a servo.

  • A temperature sensor could turn a fan on when the surrounding temperature reaches a chosen level.

  • A button connected to a lid could detect that a container has been opened and trigger an alarm.

  • A proximity sensor could activate lights or a buzzer when someone approaches.

The program defines the rules: what input values matter, what conditions must be met, and which outputs should respond. The same hardware arrangement can often be repurposed by changing the program or the story behind the device.


Electricity and Circuits

Electricity as Moving Charge

Electricity involves the movement of electric charge. In metal wires, some electrons are free to move through the material. When charges move in an organized way, an electric current flows.

A simple analogy is to imagine a track along which charges can travel. A battery provides the electrical energy that drives charge around a complete circuit. The amount of current and the voltage available affect how a component behaves.

The analogy of electrons as objects moving along a track is useful for visualizing a circuit, but it is simplified. A battery does not simply store a pile of electrons on one side that all transfer to the other. Chemical processes inside the battery maintain a voltage, which drives charge through a closed path. When a battery can no longer maintain adequate voltage under load, it is considered depleted.

Closed Circuits

An electrical circuit needs a complete, closed path for current to flow. When a wire completes the path between a battery and a bulb, current can pass through the bulb and it lights. If the path is broken, current stops and the bulb turns off.

A simple circuit can be understood as:

  1. The power source creates a voltage across its terminals.

  2. A connected path allows current to flow through the components.

  3. The components transfer electrical energy into other forms, such as light, heat, sound, or motion.

  4. The path returns to the power source, completing the circuit.

The bulb lights because electrical energy is converted into light and heat within it. The filament in a traditional incandescent bulb resists current and becomes hot enough to glow. LEDs produce light through a different physical process, but they also need a suitable circuit and current.

Switches

A switch opens or closes part of a circuit:

  • In the off position, the circuit is open, so there is no complete path for current.

  • In the on position, the circuit is closed, allowing current to flow.

A switch acts like a gate in the track analogy: it either interrupts or completes the path. A switch can be operated by a person or built into a mechanism, such as a button that changes state when a lid is lifted.


A Light-Sensitive Nightlight

A basic nightlight illustrates how inputs, processing, and outputs work together:

  1. A light sensor measures the surrounding light.

  2. The microcontroller repeatedly reads the sensor.

  3. The program compares the reading with a chosen threshold.

  4. If the environment is dark enough, the microcontroller increases the LED’s brightness or turns it on.

  5. If the environment becomes bright again, the program dims or turns off the LED.

The circuit contains paths for both sensing and driving the light. The microcontroller makes the system more adaptable than a simple direct connection between a sensor and a lamp, because its program can apply rules to the sensor’s readings.


Arduino and Microcontrollers

Arduino refers to a company and an open-source electronics platform associated with a family of microcontroller boards and development tools. An Arduino Uno is a commonly used board. Its header pins make it convenient to connect wires and electronic components.

The terms Arduino and microcontroller are related but are not identical:

  • Microcontroller: A general category of small programmable computer used to control hardware.

  • Arduino: A particular brand and platform for microcontroller boards and related tools.

Other boards can perform similar functions without being Arduino-branded. A custom-designed board may contain a microcontroller along with the other parts needed for a particular product.


Programming an Arduino

The Arduino IDE and Sketches

The Arduino IDE is software used to write or open a program and upload it to an Arduino-compatible board. After connecting the board to a computer, the user selects the appropriate board connection or port and uploads the program.

An Arduino program is commonly called a sketch. Arduino sketches use a form of C++ with functions and tools suited to controlling hardware.

A sketch typically has two main parts:

  • setup() runs once when the board starts. It is used to prepare the system, such as identifying which pins will be used and how they will behave.

  • loop() runs repeatedly after setup. It contains the instructions the board should keep performing, such as checking a sensor and deciding whether to turn on an LED.

For a nightlight, the setup stage establishes the relevant inputs and outputs. The loop then repeatedly checks the light sensor, compares its value with the program’s condition, and updates the LED.

The number of times a loop can run in a second depends on the board and the instructions it must execute. A loop may run very quickly, but the exact rate is not fixed for all programs or microcontrollers.

Comments and Executable Instructions

Code may contain comments: explanatory text for people reading the program. Comments do not control the board. In C++, text between /* and */ is a block comment; text following // on a line is also a comment.

The microcontroller executes the actual instructions in the sketch, not the explanatory comments. Comments are valuable because they help people understand what the program is intended to do.

The Blink Example

A simple first program makes an onboard LED blink. The program sets the LED pin as an output, turns the LED on, waits, turns it off, and waits again. Since these instructions are in the loop, the sequence repeats.

A delay value is commonly expressed in milliseconds:

  • 1,0001{,}0001,000 milliseconds equals one second.

  • A delay of 3,0003{,}0003,000 milliseconds is three seconds.

  • A delay of 4,0004{,}0004,000 milliseconds is four seconds.

Changing the delay values changes the blink timing. This small example demonstrates an important principle: changing a program changes how the same hardware behaves. Uploading a new sketch effectively gives the board new instructions.


Using Existing Projects and Code

Beginners do not need to create every program from scratch. Many educational projects provide both:

  • A schematic or wiring guide showing how to connect the components.

  • A program that can be copied, uploaded, and then adapted.

For example, a project might use a knob to control the position of a servo motor. As the knob’s value changes, the program changes the target position sent to the servo. The same arrangement could support many different applications, depending on the mechanism attached to the motor.

When using existing code, it is useful to understand enough to change relevant values and recognize the program’s overall structure. Copying code can be a practical starting point, but checking the wiring and adapting the program carefully helps ensure the project works as intended.

AI chat tools can assist with interpreting code, suggesting edits, explaining errors, or helping plan a project. Their suggestions should still be tested: generated code or wiring advice may be incorrect or unsuitable for the particular board and components.


Breadboards, Schematics, and Printed Circuit Boards

Solderless Breadboards

A solderless breadboard lets users build and change circuits without soldering wires permanently together. Metal contacts beneath the holes connect groups of holes electrically, so components inserted into the same connected group can share a connection.

The exact connection pattern varies by breadboard. Many common boards connect small groups of holes in the central terminal area, while long side power rails provide convenient connections for power and ground. Some power rails are split, so their continuity should not be assumed without checking the board’s layout.

Breadboards are useful for prototyping: assembling a circuit temporarily, testing it, and changing connections as needed. The internal metal strips provide electrical connections that would otherwise require wires to be joined directly.

Schematics

A schematic is a diagram that represents the electrical connections in a circuit. It shows which components connect to which others, rather than necessarily showing their physical layout. A schematic helps a builder transfer a project into a breadboard or another circuit format.

A good project guide often includes both the program and the schematic because software alone cannot make a circuit function if the components are wired incorrectly.

Printed Circuit Boards

A printed circuit board, or PCB, holds components and connects them using conductive traces built into the board. Unlike a temporary breadboard prototype, a custom PCB can combine the microcontroller, power connections, and other components into one organized design.

PCBs are used in products such as calculators, microwaves, washing machines, and cars. They are well suited to finished devices and repeated manufacturing, while breadboards are especially useful for early testing and experimentation.


From Prototype to Creative Device

A project can begin with a few sensors, a microcontroller, and outputs connected on a breadboard. Once the design has been tested and refined, it can be assembled more permanently, potentially using a custom PCB.

A productive design process is:

  1. Decide what the device should sense or respond to.

  2. Choose an input that can detect the relevant event or measurement.

  3. Choose an output that can produce the desired response.

  4. Connect the components and provide appropriate power.

  5. Write or adapt a sketch that maps the input to the output.

  6. Test the behavior and adjust the code or wiring.

  7. Package the working circuit into a practical mechanical design.

The electronics provide control, while the mechanical design determines how that control affects the physical world. A simple motor-and-knob arrangement, for example, becomes a different device depending on what the motor moves and what purpose the mechanism serves.


Key Takeaways

  • Inputs collect information from a person or the environment.

  • A microcontroller runs a program that interprets inputs and controls the system.

  • Outputs produce effects such as movement, light, or sound.

  • Wires provide electrical paths and signal connections, and a power source supplies energy.

  • Current flows through a circuit only when there is a complete electrical path.

  • A switch controls whether a path is open or closed.

  • Arduino sketches typically use a one-time setup stage followed by a repeatedly executed loop.

  • Breadboards support temporary prototyping; schematics communicate circuit connections; PCBs provide a more permanent integrated design.

  • The same electronic components can support many different projects by changing the program, the mechanical arrangement, or the way the device is used.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent