LogoLogo
Terminal
  • Attic Lab
  • Getting Started
  • Crest Gold
  • Crest Silver
  • Videos on Computation
  • PI PICO (CIRCUITPYTHON)
    • Getting Started
    • Pin Out Diagram
    • Breadboards
    • 1. Led Blink
    • 2. RGB
    • 3. OLED
    • 4. Sensors
    • 5. Wifi
    • 6. Servos
  • Arduino
    • Getting Started
    • Pin Out Diagrams
      • Mega2560 R3
    • Programming
      • Arduino C - Cheat Sheet
    • Buttons
      • Momentary Switches
    • Display
      • LEDs
      • 7 Segment Displays
      • LCD Displays (GPIO)
      • LCD Displays (SPI)
      • OLEDs
    • Communication
      • Antenna Theory
      • Lora
      • Wifi
        • Boards
    • Project Ideas
    • Motion
      • DC Motors
      • Servo Motors
      • Stepper Motors
  • Microsoft Office
    • Word
    • Powerpoint
    • Excel
  • The Terminal
    • Basics
    • Cheat Sheet
    • Games
      • Level 1 - Bashcrawl
      • Level 2 - Bandit
  • TinkerCad
    • Gallery
    • Getting Started
    • Basic Operations
    • Basic Skills
    • Projects
      • Locking Container
  • Python
    • Hello World
    • Turtle Graphics
      • Strings in Turtle Graphics
      • Cheat Sheet
    • Variables
    • Loops
    • If Statements
    • Functions
    • Games
      • Pong
  • Raspberry Pi
    • Setup
      • Changing The Hostname
      • Headless Setup
      • Kiosk Mode
    • Remote Connections
    • Displays
      • Memory
        • External HD
      • HyperPixel 4.0
  • Ultimaker 3D Printing
    • The Thingiverse
    • Preparing the File
    • Printing
    • Calibration Prints
    • Print Set
  • Fusion 360
    • Getting Started
    • Design Tutorials
      • Tweezers
      • Mars Rover Wheel
    • Surface Modeling
  • Electronics
    • References
    • Antenna Theory
    • LoRa
  • PCB Milling
    • FlatCam
    • Candle
    • PCB Milling
  • Projects
  • Projects
    • Star Map Necklace
    • Ideas Respository
  • Latex
    • What is LaTeX?
    • Getting Started
    • Structure
    • Page Size & Margins
    • Styling
    • Images
    • Lists
    • Tables
    • Mathematics
      • Superscript and Subscripts
      • List of Symbols
      • Fractions and Binomials
      • Integrals, Sums & Limits
    • Colors
  • Web Development
    • The Internet
    • Intro to HTML
    • Basic Elements
    • Basic Styling
Powered by GitBook
On this page
  • Minimum Code
  • Simple LED Blinking
  • Circuit
  • Code
  • Deploying

Was this helpful?

  1. Arduino

Getting Started

Previous6. ServosNextPin Out Diagrams

Last updated 5 years ago

Was this helpful?

Download the Arduino IDE

Minimum Code

At a minimum, each piece of Arduino code (called a sketch) must have a setup() function and a loop() function.

void setup() {
  // put your setup code here, to run once:
  // the setup function runs once when you press reset or power the board
}

void loop() {
  // put your main code here, to run repeatedly
  // the loop function runs over and over again forever
}

Any line that started withs two slashes (//) is a comment and will not be read by the compiler

Simple LED Blinking

Getting an LED to blink is pretty much the simplest thing you can do with an Arduino to see physical output.

Components

  • LED

  • 220 Ohm to 1k Ohm Resistor

  • Breadboard

  • 2 x Male-male jumper wire

To build the circuit, connect one end of the resistor to Arduino pin 13.

Connect the long leg of the LED (the positive leg, called the anode) to the other end of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the Arduino GND, as shown in the diagram and the schematic below.

Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example with no hardware attached, you should see that LED blink.

Circuit

Connect the circuit using a breadboard

Code

void setup() {
  // LED_BUILTIN is a constant that is automatically set to the correct LED pin
  // Set the LED_BUILTIN pin to be an output pin
  pinMode(LED_BUILTIN, OUTPUT);
}


void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Deploying

Open up the IDE and past in the above code

Plug in the Arduino to your computer via a usb cable. We need to tell the IDE to use the usb port. Select the plugged in Arduino from Tools > Port. You should only need to do this once.

Click upload in the IDE to copy the code over to the Arduino

Press the Reset button on the Arduino to run the code.

Software
Logo