Skip to content
Elia Cohen edited this page Oct 1, 2025 · 8 revisions

Week 1

Week 2

Note

On Blog docs: Use videos to show interactive parts!! Don't say "then the light blinked" and not show the light blinking :(

Writing Arduino code!

Arduino sketches have two main functions: setup() and loop().

  • setup(): runs once at the start of the program.
  • loop(): runs continuously once setup() has finished.

Digital Pins

  • Are one of two states, HIGH or LOW!
  • Can act as inputs or outputs using the pinMode() function.

Tip

pinMode(pin, mode)

Pins can be set to input or output mode using the pinMode() function. pinMode(13, OUTPUT) tells the Arduino to use pin 13 as an output.

digitalWrite(pin, value)

Digital output pins can be set using the digitalWrite() function. digitalWrite(13, HIGH) tell the Arduino to turn pin 13 on.

digitalRead(pin)

Digital input pins can be read using the digitalRead() function. digitalRead(13) reads whether pin 13 is HIGH or LOW.

Delays

Tip

delay(ms)

Programs can be temporarily stopped using the delay() function. delay(250) will stop the program for 250ms or one quarter-second.

Resistors

Resistors use bands to show resistance. Each color corresponds to a number:

color number
Black 0
Brown 1
Red 2
Orange 3
Yellow 4
Green 5
Blue 6
Purple 7
Grey 8
White 9

The first band is the first digit, the second band is the second digit, in a five-band resistor the third band is the third digit.

The second-last band is the multiplier (×10 ^ value).

The last band denotes tolerance:

color tolerance
brown ± 1%
red ± 2%
gold ± 5%
silver ± 10%

Tip

Resistors are not polarized. You can place them in any direction.

Week 3

Week 4

Week 4 is all about sound!

To create sound, we can fake analog output again with pulse width modulation. However, instead of changing the duty-cycle to fake less voltage, we'll change the period to fake frequency!

Tip

tone(pin, frequency, duration)

We can play audio tones using the tone() function. tone(9, 440, 500) tells the Arduino to play a 440 hz tone on pin 9 for 500 ms.

noTone()

We can stop audio tones using the noTone() function. noTone() tells the Arduino to stop playing a tone, if one is playing.

But the Arduino can't make noise by itself..

Introducing the piezo!

A piezo (or piezoelectric speaker) uses the piezoelectric effect to create audible tones. Some piezos are polarized, but not all. Piezos can also be used in reverse, to detect sound/vibration rather than produce it.

Week 5

Delays and millis()

So far, we've been using delay() to control time. However, this pauses execution, which isn't always what we want. We can use a different function millis() to get the time since the program began without stopping execution.

Caution

millis() will overflow back to zero after about 50 days.

New Part: Tilt Sensor

Tilt switches help determine the orientation of something. Accelerometers are a type of tilt sensor that gives out much more information. If you just want to know if something is up or down, a tilt switch works great!

Motors

Motors spin when the electrical energy is converted into a magnetic field. This magnetic field causes the motor to turn. However, in the same way, motors can also be used to convert motion back into electrical energy. Moving things takes a lot of energy, so a 9V battery is a must! Motors have an optimal operating voltage and will work from -50% to +50% of that voltage.

Transistors

A transistor is an electronic switch. It's like a lever or a button but it uses an electrical signal to open and close the switch instead of a physical action. Transistors have a source, a gate, and a drain. The source is the source of power from the arduino, the gate controls if it gets through or not, and the drain is where the power flows out to the motor or other component.

Warning

When you stop powering a motor, it will continue to spin to a stop. This spinning will generate power that feeds back into the arduino. We can use a diode to prevent energy from traveling back through.

Week 6

Week 6 is all about integrated circuits!

Integrated circuits are small compact circuits that are mass-produced so you don't have to create your own huge breadboard circuits. With integrated circuits we can create more complicated projects! Integrated circuits are like the electrical version of programming libraries. This week we'll be using H-bridges in LCD displays.

Logic chips are the simplest ICs. They represent logic gates, buffers, counters, latches, and other functions.

The first IC that we will use is a H-bridge. An H-bridge allows you to control the polarity of the voltage applied.

Tip

We could construct an H-bridge using discrete components, but it would probably take an entire second breadboard!

Tip

When in doubt about how to hook up an IC, always consult the spec sheet!

LCD Displays (Liquid Crystal Displays Displays)

When the crystals are angled the right way, light can pass through. The special crystals are polarized such that when electricity is applied, they orient one way or the other.

Tip

LCD displays have a lot of pins for many different uses, but not all of them are necessary. Always consult the spec sheet to see what abilities you need for your project.

Warning

A schematic may group the IC pins by what they do, rather than ordering them as they appear on the real IC. Always make sure you're really connecting each pin to the right LCD pins!

Tip

We can use the LiquidCrystal library to avoid having to get too in the weeds with the commands!

Week 7

Week 8

Week 9

Week 10

Week 11

Week 12

Week 13

Week 14

Week 15