Inputs & Outputs / Pins

Inputs & Outputs (Pins)

Programs don't just display information.

They also interact with the world around them.

How does a program know when a button is pressed?

How does an LED turn on?

How does a motor move?

The answer is pins.

Pins allow your program to communicate with electronic components like buttons, LEDs, sensors, motors, and buzzers.

 Think of pins as doors that allow information to move into and out of your program.


What Are Pins?

Pins are the connection points on the D1 R32.

They allow information to travel between your program and electronic components.


Input Example

Button

↓

Pin

↓

Program


Output Example

Program

↓

Pin

↓

LED


Inputs & Outputs Category

[INSERT CATEGORY IMAGE HERE: Inputs & Outputs]

Figure 7.1 – Blocks available in the Inputs & Outputs category.

The category can be organized into:

DIGITAL

↓

ANALOG

↓

PWM


Block Guide

BlockBlock ImageWhat It DoesWhat the Options Mean
HIGH / LOW[ INSERT BLOCK IMAGE: HIGH / LOW ]Provides a digital logic value.HIGH represents 1. LOW represents 0.
Setup Digital Pin[ INSERT BLOCK IMAGE: Setup Digital Pin ]Configures a selected pin for digital operation.PIN# selects the physical pin. Digital Output configures the pin as an output. The available setup mode should be selected according to whether the pin will send or receive a digital signal.
Digital Output[ INSERT BLOCK IMAGE: Digital Output ]Sets the selected digital output to HIGH or LOW.HIGH → 1 and LOW → 0.
Digital Input[ INSERT BLOCK IMAGE: Get Digital Input ]Reads the current digital value of a pin.The returned value represents the current digital state of the selected pin.
Setup Analog Input[ INSERT BLOCK IMAGE: Setup ADC ]Configures an ADC input on the selected analog-capable pin.The selected pin determines which ADC input is created.
ADC Attenuation[ INSERT BLOCK IMAGE: ADC Ref Voltage Stat ]Changes the ADC attenuation setting, which changes the input-voltage range handled by the ADC.Available generated settings: ATTN_11DB, ATTN_6DB, ATTN_2_5DB, ATTN_0DB.
ADC Resolution[ INSERT BLOCK IMAGE: ADC Resolution Stat ]Configures the ADC reading resolution.Available generated resolutions: 12-bit, 11-bit, 10-bit, 9-bit.
Get Analog Input[ INSERT BLOCK IMAGE: Get Analog Input ]Reads the selected ADC input.Clu-Blocks Pro generates an analog reading using read_u16().
Setup PWM Output[ INSERT BLOCK IMAGE: Setup PWMAnalog Output ]Configures the selected pin for PWM output.PIN# selects the PWM-capable output pin.
PWM Value[ INSERT BLOCK IMAGE: PWMAnalog Output value ]Sets the PWM duty value.The numerical input determines the generated PWM duty value.
PWM Frequency[ INSERT BLOCK IMAGE: PWMAnalog Output frequencyStat ]Sets the PWM frequency.The numerical field specifies the frequency used by the PWM output.
Attach Interrupt[ INSERT BLOCK IMAGE: attachInterrupt ]Configures a pin to trigger a function when the selected signal change occurs.Available generated triggers are RISING, FALLING, and RISING + FALLING.
Interrupt Function[ INSERT BLOCK IMAGE: attachInterrupt_func ]Contains the instructions executed by the interrupt handler.The visible function is attachInterrupt_func.
Setup DAC Output[ INSERT BLOCK IMAGE: Setup DACAnalog Output ]Configures a DAC-capable pin for analog output.PIN# selects the DAC output pin.
DAC Output[ INSERT BLOCK IMAGE: DACAnalog Output ]Sends a numerical value to the configured DAC output.The numerical input provides the DAC output value.

🔢 HIGH and LOW

Digital electronics use two states:

StateMeaning
HIGHON
LOWOFF

Example

HIGH

↓

LED ON


LOW

↓

LED OFF

 Digital means ON or OFF.


 Digital Output

[INSERT BLOCK IMAGE HERE: Digital Output]

Digital Output sends a signal from the program to a component.

Example

Program

   ↓

Digital Output

   ↓

LED


Common Uses

 LEDs

 Buzzers

 Relays

 Simple modules


 Digital Input

[INSERT BLOCK IMAGE HERE: Digital Input]

Digital Input reads a signal from a component.

Example

Button

   ↓

Digital Input

   ↓

Program


Common Uses

 Push buttons

 Switches

 Motion sensors

 Digital sensors


 Analog Input

[INSERT BLOCK IMAGE HERE: Analog Input]

Unlike digital signals, analog values can change continuously.

Example

A potentiometer might produce:

0

↓

2000

↓

4095


Concept

Sensor

   ↓

Analog Value

   ↓

Program


 Analog means "how much" instead of simply ON or OFF.


 PWM Output

[INSERT BLOCK IMAGE HERE: PWM Output]

PWM allows you to control the strength of an output.

Example

Low PWM

↓

Dim LED


High PWM

↓

Bright LED


Common Uses

 LED brightness

 Motor speed

 Servo control

 Sound generation


Easy Memory Rule

PWM Value

↓

How much output


Inputs vs Outputs

TypeDirection
InputInto the Program
OutputOut of the Program

Input

Button

   ↓

Program

Output

Program

   ↓

LED


 Inputs bring information IN. Outputs send information OUT.


Inputs + Logic + Outputs

Most robotics projects follow the same pattern:

INPUT

   ↓

THINK

   ↓

OUTPUT

Example:

Button Pressed?

↓

TRUE

↓

LED ON


Beginner Pins Projects

 Push Button LED

Button

   ↓

Program

   ↓

LED

Skills:

 Digital Input

 Digital Output

 Logic


 Traffic Light

Program

   ↓

LED Outputs

Skills:

 Outputs

 Timing

 Control


 Brightness Controller

Potentiometer

      ↓

Analog Input

      ↓

PWM

      ↓

LED

Skills:

 Analog Input

 PWM

 Math


Quick Guide for Students

Need ON or OFF?

Use:

Digital

Need a button?

Use:

Digital Input

Need to turn something on?

Use:

Digital Output

Need a changing sensor value?

Use:

Analog Input

Need brightness or speed control?

Use:

PWM


Quick Reference

FamilyMain Idea
HIGH / LOWON or OFF
Digital InputRead signals
Digital OutputControl components
Analog InputRead changing values
PWMControl brightness or speed

Summary

In this lesson, you learned how pins connect your program to the real world.

You explored:

 Digital Inputs

 Digital Outputs

 HIGH and LOW

 Analog Inputs

 PWM Outputs

Pins allow your program to communicate with buttons, LEDs, sensors, motors, and many other electronic components.


Recommended Learning Progression

HIGH / LOW

   ↓

DIGITAL OUTPUT

   ↓

DIGITAL INPUT

   ↓

ANALOG INPUT

   ↓

PWM


Key Takeaway

 Pins are the connection points between your code and the real world. They allow your program to receive information from sensors and send instructions to LEDs, motors, buzzers, and other electronic components.