Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added arduino/assets/og/buttons.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/force-sensitive-resistors.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/led-blink.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/led-blink2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/led-blink3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/led-fade.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/led-on.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduino/assets/og/rgb-led.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed arduino/assets/videos/ArduinoIDE_Compile.gif
Binary file not shown.
Binary file added arduino/assets/videos/ArduinoIDE_Compile.mp4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed arduino/assets/videos/Arduino_LEDBlink_Pin3.gif
Binary file not shown.
Binary file modified arduino/assets/videos/Arduino_LEDBlink_Pin3.mp4
Binary file not shown.
Binary file not shown.
Binary file removed arduino/assets/videos/Arduino_LEDFade_Pin3.gif
Binary file not shown.
Binary file added arduino/assets/videos/Arduino_LEDFade_Pin3.mp4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed arduino/assets/videos/Arduino_LEDOn_5VFixed.gif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
20 changes: 14 additions & 6 deletions arduino/buttons.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L1: Using buttons
description: "Build your first interactive Arduino circuit: read a push button with digitalRead() and learn why pull-up and pull-down resistors solve the floating-pin problem."
image: /arduino/assets/videos/Arduino_Button_InternalLED_Animation_Edited.gif
image: /arduino/assets/og/buttons.jpg
nav_order: 1
parent: Input
grand_parent: Intro to Arduino
Expand Down Expand Up @@ -37,7 +37,9 @@ For example, in the animation below, we show a button circuit with a pull-down r
> - How to use `digitalRead()` and `pinMode()` for digital input
> - How to select appropriate pull-up/pull-down resistor values

![Animation showing an Arduino Uno and a button hooked up to Pin 2 with a pull-down resistor configuration. When the button is pressed, the animation shows the current going from Vcc through the button and down through the pull-down resistor](assets/videos/Arduino_Button_InternalLED_Animation_Edited.gif)
<video autoplay loop muted playsinline aria-label="Animation showing an Arduino Uno and a button hooked up to Pin 2 with a pull-down resistor configuration. When the button is pressed, the animation shows the current going from Vcc through the button and down through the pull-down resistor">
<source src="assets/videos/Arduino_Button_InternalLED_Animation_Edited.mp4" type="video/mp4" />
</video>
Animation shows the Arduino's built-in LED illuminating when the button on Pin 2 is pressed. When the button is pressed, current flows from $$V_{CC}$$ through the pull-down resistor to GND. We'll learn more about this circuit in this lesson.
{: .fs-1 }

Expand Down Expand Up @@ -177,7 +179,9 @@ Given how we built button-based circuits above—without a microcontroller—you

However, if you do this, what will the digital input pin read when the switch is **open** (that is, when the button is **not** pressed)? Well, this is called a "floating pin" and it's not good. Because the input pin has extremely high impedance, it effectively acts like a tiny antenna—even minuscule charge transfers from nearby electric fields, your body's capacitance, or crosstalk between wires can swing the voltage. A floating pin is susceptible to picking up this stray electromagnetic interference, causing it to randomly oscillate between `HIGH` and `LOW`. See the animation below.

![Animation showing a floating pin condition when a button is just hooked up to 5V without a pull-down resistor](assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-FloatingPin-Optimized.gif)
<video autoplay loop muted playsinline aria-label="Animation showing a floating pin condition when a button is just hooked up to 5V without a pull-down resistor">
<source src="assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-FloatingPin-Optimized.mp4" type="video/mp4" />
</video>
**Figure.** Animation of what happens when you press a button with the simple circuit configuration.
{: .fs-1 }

Expand Down Expand Up @@ -223,7 +227,9 @@ And you're on the right track. Now, when the switch is open, the digital input p

<!-- TODO: expand on why short circuits are bad? -->

![Animation showing a button circuit without a pull-down resistor causing a short when the button is pressed](assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-ShortCircuit-Optimized.gif)
<video autoplay loop muted playsinline aria-label="Animation showing a button circuit without a pull-down resistor causing a short when the button is pressed">
<source src="assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-ShortCircuit-Optimized.mp4" type="video/mp4" />
</video>
**Figure.** Animation showing the effect of connecting `GND` without a resistor. A short circuit!
{: .fs-1 }

Expand All @@ -241,7 +247,9 @@ The pull-down resistor is quite large: 10,000Ω (10kΩ)

Here's an animation showing how a pull-down resistor configuration works. Notice how (almost) none of the current goes into Pin 2. This is because, as stated above, the digital input pins “*are in a high-impedance state*” equivalent to a 100,000,000Ω (100MΩ) resistor (see [Arduino docs](https://docs.arduino.cc/learn/microcontrollers/digital-pins/)). And remember, microcontrollers read voltage, not current (so we don't need current into our input pin)!

![Animation showing the correct operation of digital input with a pull-down resistor configuration](assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-PullDownResistor-Optimized.gif)
<video autoplay loop muted playsinline aria-label="Animation showing the correct operation of digital input with a pull-down resistor configuration">
<source src="assets/videos/Arduino_Button_SchematicsAndDiagrams_PullDownResistorWalkthrough_Animation-PullDownResistor-Optimized.mp4" type="video/mp4" />
</video>

And here's a video demonstrating the floating pin problem and fix:

Expand Down Expand Up @@ -531,4 +539,4 @@ Things to remember:

## Tinkercad circuits
- https://www.tinkercad.com/things/9skzhTypQRh-button-with-breadboard/
- https://www.tinkercad.com/things/hlkxqsvSz2E-button-no-breadboard -->
- https://www.tinkercad.com/things/hlkxqsvSz2E-button-no-breadboard -->
8 changes: 5 additions & 3 deletions arduino/force-sensitive-resistors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L5&#58; Force-Sensitive Resistors
description: "Use force-sensitive resistors (FSRs) and other two-legged variable resistors with Arduino via a voltage divider, then build a force-controlled musical instrument with map() and tone()."
image: /arduino/assets/videos/FSR_LEDCircuit_ArduinoForPower_WorkbenchWithAmmeter.gif
image: /arduino/assets/og/force-sensitive-resistors.jpg
nav_order: 5
parent: Input
grand_parent: Intro to Arduino
Expand Down Expand Up @@ -33,7 +33,9 @@ This lesson directly builds on the prior one ([potentiometers](potentiometers.md
> - How to use `map()` to convert between different value ranges
> - How to build a force-controlled musical instrument combining `analogRead` and `tone()`

![Animation showing an FSR pressing down and an LED getting brighter as resistance drops](assets/videos/FSR_LEDCircuit_ArduinoForPower_WorkbenchWithAmmeter.gif)
<video autoplay loop muted playsinline aria-label="Animation showing an FSR pressing down and an LED getting brighter as resistance drops">
<source src="assets/videos/FSR_LEDCircuit_ArduinoForPower_WorkbenchWithAmmeter.mp4" type="video/mp4" />
</video>

**Figure.** Animation shows how the resistance of the FSR drops with applied pressure (higher pressure, lower resistance, brighter LED).
{: .fs-1 }
Expand Down Expand Up @@ -312,4 +314,4 @@ You've come a long way — from blinking an LED to building force-controlled ins
<div class="nav-label">&larr; Previous Lesson</div>
<div class="nav-title">Potentiometers</div>
</a>
</nav>
</nav>
14 changes: 10 additions & 4 deletions arduino/led-blink.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L2&#58; Blinking an LED
description: "Write your first Arduino sketch to blink an LED by programmatically toggling a GPIO pin HIGH and LOW with digitalWrite()—your entrée into combining circuits and code."
image: /arduino/assets/videos/Arduino_LEDBlink_Pin3.gif
image: /arduino/assets/og/led-blink.jpg
nav_order: 2
parent: Output
grand_parent: Intro to Arduino
Expand Down Expand Up @@ -30,7 +30,9 @@ In our [first lesson](led-on.md), we directly hooked up an LED circuit to the Ar

In this lesson, we are going to do something more exciting: use the Arduino to turn the LED on and off by *programmatically* controlling the output voltage on one of Arduino's GPIO pins. This begins our entrée into the two key aspects of working with microcontrollers: (1) building circuits and (2) writing code to interact with those circuits.

![Animation showing an LED connected to Pin 3 on the Arduino blinking on and off](assets/videos/Arduino_LEDBlink_Pin3.gif)
<video autoplay loop muted playsinline aria-label="Animation showing an LED connected to Pin 3 on the Arduino blinking on and off">
<source src="assets/videos/Arduino_LEDBlink_Pin3.mp4" type="video/mp4" />
</video>

<!-- TODO: Add in a version that makes a tone for accessibility reasons?
See: https://itp.nyu.edu/physcomp/labs/labs-arduino-digital-and-analog/digital-input-and-output-with-an-arduino/ -->
Expand Down Expand Up @@ -184,7 +186,9 @@ We did it! Now it's time to compile and upload the code to Arduino.

Compile the code by clicking on the "verify" checkmark button in the upper-left corner of the Arduino IDE. If you haven't already, the Arduino IDE will also ask you to save your sketch. If there are any syntax or other identifiable errors in the code, the Arduino IDE will print them out in the console window at the bottom.

![Animation showing how to compile and save a sketch in the Arduino IDE](assets/videos/ArduinoIDE_Compile.gif)
<video autoplay loop muted playsinline aria-label="Animation showing how to compile and save a sketch in the Arduino IDE">
<source src="assets/videos/ArduinoIDE_Compile.mp4" type="video/mp4" />
</video>

### Step 5: Upload the code to Arduino

Expand All @@ -202,7 +206,9 @@ Once uploading is complete, the code automatically runs on the Arduino and the L

Here's an illustrative animation of what's happening in your circuit when the Arduino drives Pin 3 `HIGH`—hopefully, this matches your conceptual understanding as well:

![Animation showing the LED on Pin 3 turning on](assets/videos/Arduino_LEDTurnOn_Pin3ArduinoPluggedIn-Cropped.gif)
<video autoplay loop muted playsinline aria-label="Animation showing the LED on Pin 3 turning on">
<source src="assets/videos/Arduino_LEDTurnOn_Pin3ArduinoPluggedIn-Cropped.mp4" type="video/mp4" />
</video>

## Turn on and off the LED programmatically via Pin 3

Expand Down
12 changes: 8 additions & 4 deletions arduino/led-blink2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L6&#58; Blinking Two LEDs
description: "Understand current sourcing vs. current sinking by blinking two LEDs on a breadboard—one circuit where the Arduino pin sources current and one where it sinks it."
image: /arduino/assets/videos/Arduino_Blink2Animation_Pins3And4-NoSchematic-Optimized.gif
image: /arduino/assets/og/led-blink2.jpg
nav_order: 6
parent: Output
grand_parent: Intro to Arduino
Expand Down Expand Up @@ -30,7 +30,9 @@ We are going to build two simple LED circuits:

Yes, this can be a bit confusing at first ("*wait, the LED turns off when Pin 4 is `HIGH`?!?!*"). But you'll gain understanding by completing this lesson. In the animation below, pay attention to the current direction in each circuit. Notice how they're opposite!

![Animation showing how driving Pin 3 and 4 HIGH will turn on LED Circuit 1 and off LED Circuit 2 and driving those pins LOW will turn off LED Circuit 1 and on LED Circuit 2](assets/videos/Arduino_Blink2Animation_Pins3And4-NoSchematic-Optimized.gif)
<video autoplay loop muted playsinline aria-label="Animation showing how driving Pin 3 and 4 HIGH will turn on LED Circuit 1 and off LED Circuit 2 and driving those pins LOW will turn off LED Circuit 1 and on LED Circuit 2">
<source src="assets/videos/Arduino_Blink2Animation_Pins3And4-NoSchematic-Optimized.mp4" type="video/mp4" />
</video>

## Materials

Expand Down Expand Up @@ -117,7 +119,9 @@ void loop() {

We did it! Now compile and upload the code.

![Top-down workbench animated gif of the circuit working with Arduino](assets/videos/ArduinoUno_Blink2_Workbench.gif)
<video autoplay loop muted playsinline aria-label="Top-down workbench animated gif of the circuit working with Arduino">
<source src="assets/videos/ArduinoUno_Blink2_Workbench.mp4" type="video/mp4" />
</video>

And here's a top-down video with the code window:

Expand Down Expand Up @@ -168,4 +172,4 @@ In the [next lesson](rgb-led.md), we will use a new component—an RGB LED—to
<div class="nav-label">Next Lesson &rarr;</div>
<div class="nav-title">RGB LEDs</div>
</a>
</nav>
</nav>
8 changes: 5 additions & 3 deletions arduino/led-blink3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L9&#58; Rate Blinking LEDs
description: "Blink multiple LEDs at different rates without delay() and write your first C++ class to eliminate redundant code and shrink your Arduino sketch."
image: /arduino/assets/videos/ArduinoUno_BlinkMultiple_Workbench.gif
image: /arduino/assets/og/led-blink3.jpg
nav_order: 9
parent: Output
grand_parent: Intro to Arduino
Expand All @@ -25,7 +25,9 @@ In this lesson, we will learn how to blink multiple LEDs at different rates and

As with our previous lesson on [crossfading RGB LEDs](rgb-led-fade.md), this lesson involves **simple circuits** but comparatively **complex code**. Often, when using microcontrollers, our code is the magic sauce—the circuits are straightforward but the code can be complicated.

![Animated gif of a workbench video recording showing BlinkMultiple.ino](assets/videos/ArduinoUno_BlinkMultiple_Workbench.gif)
<video autoplay loop muted playsinline aria-label="Animated gif of a workbench video recording showing BlinkMultiple.ino">
<source src="assets/videos/ArduinoUno_BlinkMultiple_Workbench.mp4" type="video/mp4" />
</video>

## Background

Expand Down Expand Up @@ -371,4 +373,4 @@ We did it! This completes our [Intro to Output](intro-output.md) series. Let's n
<div class="nav-label">Next Lesson &rarr;</div>
<div class="nav-title">Cross-fading RGB LEDs</div>
</a>
</nav> -->
</nav> -->
8 changes: 5 additions & 3 deletions arduino/led-fade.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L4&#58; Fading an LED
description: "Smoothly fade an LED on and off with Arduino's analogWrite() and pulse-width modulation (PWM), controlling output voltage at fine gradations beyond just HIGH/LOW."
image: /arduino/assets/videos/Arduino_LEDFade_Pin3.gif
image: /arduino/assets/og/led-fade.jpg
nav_order: 4
parent: Output
grand_parent: Intro to Arduino
Expand All @@ -23,7 +23,9 @@ usetocbot: true

In the [previous lesson](led-blink.md), we learned how to turn on and off an LED using [`digitalWrite`](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite/)—which worked by alternately setting Pin 3 to 5V (`HIGH`) and 0V (`LOW`). In this lesson, we'll learn how to programmatically control the output voltage at finer gradations using [`analogWrite`](https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/). More specifically, we will gradually fade an LED on and off like the animation below illustrates.

![Animation showing the LED on Pin 3 gradually fading on and off](assets/videos/Arduino_LEDFade_Pin3.gif)
<video autoplay loop muted playsinline aria-label="Animation showing the LED on Pin 3 gradually fading on and off">
<source src="assets/videos/Arduino_LEDFade_Pin3.mp4" type="video/mp4" />
</video>
**Figure.** This illustrative animation doesn't show current (the yellow circles) only due to my limited animation skills. But hopefully you can visualize (in your mind) how the LED varies in brightness with current just the same. :)
{: .fs-1 }

Expand Down Expand Up @@ -304,4 +306,4 @@ In the [next lesson](tone.md), we'll learn how to play sounds on a piezo buzzer!
<div class="nav-label">Next Lesson &rarr;</div>
<div class="nav-title">Playing Tones</div>
</a>
</nav>
</nav>
14 changes: 9 additions & 5 deletions arduino/led-on.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: default
title: L1&#58; Turning on an LED
description: "Your first Arduino activity: wire an LED to the 5V and GND pins to light it up—no code required—and build familiarity with Arduino hardware and current flow."
image: /arduino/assets/videos/Arduino_LEDOn_5VFixed_USBPower.gif
image: /arduino/assets/og/led-on.jpg
nav_order: 1
parent: Output
grand_parent: Intro to Arduino
Expand All @@ -22,7 +22,9 @@ usetocbot: true
---
For our first learning activity, we are going to use Arduino to turn on an [LED](../electronics/leds.md). We're **not** going to write any code. Instead, our goal is to build some initial familiarity with Arduino hardware and connecting components to Arduino pins before we introduce programming, which we do in the [next lesson](led-blink.md).

![Animation showing a USB cable plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND](assets/videos/Arduino_LEDOn_5VFixed_USBPower.gif)
<video autoplay loop muted playsinline aria-label="Animation showing a USB cable plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND">
<source src="assets/videos/Arduino_LEDOn_5VFixed_USBPower.mp4" type="video/mp4" />
</video>
**Figure.** The movement of **current** in the circuit is illustrated by the animated yellow circles. This visualization is a coarse abstraction designed to emphasize the direction of current flow. A more accurate visualization would show that electrons are already distributed throughout a wire before a voltage is applied. See our [Introduction to Electronics](../electronics/index.md) series, specifically the lesson on [Voltage, Current, and Resistance](../electronics/electricity-basics.md).
{: .fs-1 }

Expand Down Expand Up @@ -62,7 +64,9 @@ Insert the LED + resistor into the Arduino:

Make sure to push the legs down so they are well seated inside the Arduino's female headers.

![Animation of LED + resistor being connected to Arduino's GND and 5V ports](assets/videos/Arduino_LEDOn_5VFixed_InsertLED.gif)
<video autoplay loop muted playsinline aria-label="Animation of LED + resistor being connected to Arduino's GND and 5V ports">
<source src="assets/videos/Arduino_LEDOn_5VFixed_InsertLED.mp4" type="video/mp4" />
</video>

### Step 3: Connect your Arduino to power

Expand All @@ -76,7 +80,7 @@ For power, you can use a USB cable (which supplies 5V) or a 9V battery (which su

| USB Power | 9V Power |
|:-------------|:------------------|
| ![Animation showing a USB cable plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND](assets/videos/Arduino_LEDOn_5VFixed_USBPower-Cropped.gif) | ![Animation showing a 9V battery plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND](assets/videos/Arduino_LEDOn_5VFixed_9VBattery-Cropped.gif) |
| <video src="assets/videos/Arduino_LEDOn_5VFixed_USBPower-Cropped.mp4" autoplay loop muted playsinline aria-label="Animation showing a USB cable plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND"></video> | <video src="assets/videos/Arduino_LEDOn_5VFixed_9VBattery-Cropped.mp4" autoplay loop muted playsinline aria-label="Animation showing a 9V battery plugging into an Arduino Uno to power an LED + resistor hooked up to 5V and GND"></video> |
| With USB power, the 5V pin supplies 5V | Using the Arduino's barrel jack, we can connect an external power supply like a 7-12V wall adapter or a 9V battery. The Arduino's internal voltage regulator reduces these higher voltages to output a clean 5V |

{: .warning }
Expand Down Expand Up @@ -341,4 +345,4 @@ In the next lesson, we will learn how to programmatically control the output vol
<div class="nav-label">Next Lesson &rarr;</div>
<div class="nav-title">Blinking an LED with Arduino</div>
</a>
</nav>
</nav>
Loading
Loading