1 of 10

Input & output in the Arduino IDE

Prototyping electronics on a breadboard and writing code

2 of 10

Arduino

  • Hardware
    • Prototyping with breadboard, components, wires
    • XIAO ESP32S3
  • Software
    • Programming in the Arduino IDE
  • We’re going to focus first on building circuit examples and using/modifying example code

3 of 10

4 of 10

Writing on/off: digitalWrite

Blink_LED.ino

HIGH/LOW

Output

5 of 10

Writing a range of values: analogWrite()

Fade_LED.ino

PWM: 0-255

Output

6 of 10

Reading on/off: digitalRead()

digital_switch_LED.ino

You can detect if a pin is HIGH or LOW

For example: in the case of a switch, whether it’s pressed or not

pinMode(INPUT_PULLUP); to use internal pullup resistor

Input

7 of 10

Measuring resistance: analogRead()

LDR_Fade_LED.ino

With a microcontroller you can measure how much resistance a (DIY) sensor (input) gives. The more difficult the current moves through it, the higher the resistance.

You can read this with analogRead(): voltages (between 0-3.3V in our case) are converted to numbers (0-4095).

You can then link these numbers to something else (output) with map().

Input

8 of 10

Measuring capacitance: touchRead()

touch_keyboard_speaker.ino

Detects variations in anything that holds an electrical charge - including you!

Input

9 of 10

Writing a range of values: servo motor angle

LDR_Servo_motor.ino

Library: ESP32Servo.h

10 of 10

References