Arduino Workshop Notes

Jul 29, 2024

Arduino Workshop Notes

Welcome to this Arduino workshop! Here you will learn the essentials of Arduino, programming, and building electronic projects.

Overview of Arduino

  • Definition: Arduino is a tool that allows you to control electronic components through code.
  • Electronic Components:
    • Inputs: Sensors (temperature, light, touch, humidity, etc.)
    • Outputs: Motors (DC, stepper, servo), LEDs, displays, buzzers, etc.
  • Functionality: Reads inputs and controls outputs based on your code logic.

Getting Started with Arduino

Required Components

  1. Arduino Board:
    • A microcontroller-based circuit board.
    • Common choice: Arduino Uno Rev 3.
  2. Arduino IDE: Integrated Development Environment to write and upload your code.
  3. Arduino Code (Sketch):
    • The code you write for Arduino, utilizing C/C++ with Arduino-specific features.

Types of Arduino Boards

  • Arduino Uno: Best for beginners, supports multiple accessories/shields, and commonly used in examples.
  • Arduino Mega/Nano: Other options that may also work fine.
  • Open Source: Arduino hardware and software are open source, allowing compatibility with various boards from different manufacturers.

Getting an Arduino Board

  • Buying an Arduino: If you haven't purchased yet, consider getting the Arduino Uno Rev 3 from the Arduino website.
  • No Money? Use Tinkercad for free online Arduino simulation.

Arduino Board Hardware

Main Components

  1. Microcontroller: The "brain" of the Arduino that executes code.
  2. Pins:
    • GPIO Pins: General-purpose input/output pins for connecting sensors and controlling outputs.
    • Analog Pins: Used for reading continuous signals.
    • Power Pins: 5V and 3.3V supply for connected components.
  3. LEDs: Indicator lights on the board for signaling.

Powering the Arduino

  • 3 ways to power:
    1. Via USB connection.
    2. DC jack for external power (7 to 20 volts recommended).
    3. External voltage source via the V_in pin.

Writing Code with Arduino IDE

Setting Up Arduino IDE

  • Download Arduino IDE from the official site:
    • Options: Arduino IDE 1.0, Arduino IDE 2.0 (in development), and Web Editor.
  • Familiarize yourself with Example Sketches available within Arduino IDE to learn coding patterns.

Basic Code Structure

  • Two key functions in every Arduino program:
    • setup(): Runs once; used for initial configurations (e.g., pin modes).
    • loop(): Runs repeatedly; contains the main logic of the program.
  • Variables: Basic data buckets to store information.
    • Types: int, float, boolean, etc.
  • Control Structures: Logic flow controls using if, else, switch, etc.

Important Arduino Functions

  1. pinMode(): Sets a pin as input or output.
  2. digitalWrite(): Outputs a HIGH or LOW voltage to a pin.
  3. analogWrite(): Controls PWM for devices like motors or LEDs.
  4. analogRead(): Reads voltages from analog pins.
  5. delay(): Pauses program execution for a set time.
  6. Serial monitor functions for debugging and communication.

Using Libraries

  • Definition: Pre-written code for specific hardware interactions.
  • Installation: Libraries can be found via the library manager within the Arduino IDE.
  • Example Libraries: Servo control, LED strip control (Neopixel), etc.

Example Projects

  1. Knob Control with Servo: Control a servo motor using a potentiometer.
  2. Button Control: Turning an LED on/off with a button press.
  3. Using Sensors: Reading sensor data and reacting using control structures.

Conclusion

  • Arduino programming fundamentals will help you get started with electronics.
  • Encourage to explore more libraries and utilize the community for troubleshooting.
  • Further Training: Check out Programming Electronics Academy for in-depth tutorials and courses.

Special Thanks

  • Thanks to Altium for sponsoring this workshop and providing access to software helpful in electronics design.