Bluetooth: Receive

Bluetooth: Receive

Many modern devices exchange information wirelessly.

For example:

  • Smartphones
  • Tablets
  • Computers
  • Robots
  • Game controllers
  • Smart devices

One of the most common wireless communication technologies is Bluetooth.

The Bluetooth: Receive category allows a D1 R32 to receive information from another Bluetooth device.

The received information can then be:

 Displayed on the PC using Serial

 Stored in variables

 Shown on an LCD or OLED

 Compared with commands

 Used to control LEDs, servos, buzzers, and motors

 Used to create complete remote-control systems


Introduction

Imagine controlling a robot with your phone.

You press a button on the phone and the robot moves forward.

No wires connect them.

Instead, the phone sends information through Bluetooth.

The robot receives that information and reacts.

Conceptually:

Phone

↓

Bluetooth

↓

D1 R32

↓

Action

This is the purpose of the Bluetooth Receive category.

It provides the wireless input channel of the program.


What Is Bluetooth Receive?

Bluetooth Receive allows information to enter the D1 R32 wirelessly.

Conceptually:

Other Device

↓

Bluetooth

↓

D1 R32

↓

Program

The information can be:

  • Text
  • Commands
  • Numbers
  • Sensor information
  • Status messages

The D1 R32 can then decide what to do with that information.


Why Use Bluetooth?

Bluetooth communication makes it possible to control projects wirelessly.

Examples include:

Phone-controlled robots

 Wireless LED control

 Wireless servo control

 Remote sensor monitoring

 Wireless displays

 Communication between devices

 Robot control apps


Bluetooth Category

[INSERT CATEGORY IMAGE HERE: Bluetooth Receive]

Figure 12.1 – Blocks available in the Bluetooth Receive category.

The easiest way to understand this category is:

RECEIVE

↓

OBSERVE

↓

INTERPRET

↓

COMPARE

↓

ACT

This pattern should be used throughout all Bluetooth exercises.


Understanding Communication Direction

Before using Bluetooth, students should understand the direction information travels.


Bluetooth Send

D1 R32

↓

Bluetooth Device

Information leaves the D1 R32.

Bluetooth Receive

Bluetooth Device

↓

D1 R32

Information enters the D1 R32.


Memory Rule

 SEND = OUT

 RECEIVE = IN


Basic Bluetooth Communication Model

The simplest Bluetooth communication system contains two devices.

Sender

Creates information.

Phone

↓

Bluetooth Message


Receiver

Obtains that information.

D1 R32

↓

Program


Communication Flow

Bluetooth Device

↓

Wireless Message

↓

D1 R32

↓

Program


Bluetooth Message Handler

[INSERT BLOCK IMAGE HERE: Bluetooth Handle Receive Message]

One of the most important Bluetooth blocks listens for incoming information.

Conceptually:

Message Arrives

↓

Run Instructions

This allows the D1 R32 to react immediately when Bluetooth information arrives.


Example Block Concept

Bluetooth Receive Message

↓

Callback

↓

Run Instructions


Actual Generated Structure

The block creates a message-receive callback structure.

Students do not need to write this manually.

Conceptually the block behaves like:

When Bluetooth Message Arrives

↓

Execute Blocks Inside


Working With Received Data

[INSERT BLOCK IMAGE HERE: Handle Method Keys]

The callback provides received values that can be used by the program.

Examples:

key1

key2

key3

keyx

These values represent information received from the Bluetooth device.

The values can be used to:

  • Control motors
  • Turn LEDs on and off
  • Move servos
  • Play sounds
  • Display messages

Observe Data First

The first destination for received Bluetooth information should always be the Serial Monitor.


Concept

Bluetooth Device

↓

Bluetooth Receive

↓

Serial Monitor

↓

PC


Example

If a phone sends:

Hello

the D1 R32 should first display:

Hello

in the Serial Monitor.


Important Rule

 Before controlling hardware with received information, first display that information on the PC.


Printing Received Information

[INSERT BLOCK IMAGE HERE: Print Received Data]

A common beginner exercise is printing all received values.

Conceptually:

key1

key2

key3

keyx

↓

Serial Monitor

This allows students to see exactly what information arrived.


Storing Received Information

Once information has been received, it can be stored.

Conceptually:

Bluetooth Receive

↓

Variable

↓

Use Later

Example:

received_message

The variable can then be used by:

  • Logic
  • Displays
  • Control
  • Outputs
  • Other calculations

Receiving Commands

Bluetooth becomes much more useful when received messages are interpreted as commands.

Example:

A phone transmits:

ON

The D1 R32 receives:

ON

and performs an action.


Communication Flow

Phone

↓

"ON"

↓

Bluetooth

↓

D1 R32

↓

Action


Comparing Commands

Bluetooth commands become useful when combined with Logic.


Example

Received Message

↓

Equals "ON"?

↓

True / False


Concept

RECEIVE

↓

COMPARE

↓

DECIDE

This forms the basis of wireless control systems.


Controlling Outputs

Once Logic identifies the command, Control blocks can determine what happens.


Example 1

Message = "ON"

↓

LED ON


Example 2

Message = "OFF"

↓

LED OFF


Programming Model

MESSAGE

↓

MEANING

↓

ACTION


One Command, One Action

The first Bluetooth control project should stay simple.

Example:

ON

↓

LED ON

Then later:

OFF

↓

LED OFF

Only after students understand this relationship should additional commands be added.


Multiple Commands

Eventually several commands can control different behaviors.

Examples:

FORWARD

↓

Move Forward

BACKWARD

↓

Move Backward

LEFT

↓

Turn Left

RIGHT

↓

Turn Right

STOP

↓

Stop Motors


Communication Pattern

RECEIVE

↓

IDENTIFY

↓

ACT


Bluetooth Send Data

[INSERT BLOCK IMAGE HERE: Bluetooth Send Data]

Bluetooth communication does not need to be one-way.

The D1 R32 can send information back.


Example

Send:

"Clu-Bots"

Back to the phone.

Conceptually:

Receive Command

↓

Process Command

↓

Send Response

This allows two-way communication.


Checking the Connection

[INSERT BLOCK IMAGE HERE: Bluetooth Connection Status]

Before reacting to incoming commands, programs can check whether Bluetooth is connected.

Conceptually:

Connected?

↓

True / False


Example

IF Connected

↓

Allow Control


Memory Rule

No Bluetooth Connection = No Wireless Control


Local MAC Address

[INSERT BLOCK IMAGE HERE: Get Local MAC Address]

Every Bluetooth device has an identifier called a MAC Address.

Conceptually:

Robot Identity

This can help identify a specific robot during pairing and communication.


Bluetooth + LCD

Received information can be displayed on an LCD.

Conceptually:

Bluetooth Message

↓

LCD

Example:

Hello

↓

Displayed on the screen.


Bluetooth + OLED

The same concept works with OLED displays.

Bluetooth

↓

Text

↓

OLED

The communication method stays the same.

Only the output changes.


Bluetooth + Servo Motors

Bluetooth commands can control motion.

Example:

LEFT

↓

Bluetooth Receive

↓

Logic

↓

Servo

Clu-Blocks Servo Reference

When controlling a continuous rotation servo:

servo.servo360_speed(pin, value)

or

servo.servo360_speed(pin)

Bluetooth provides the command.

The servo block creates the physical movement.


Bluetooth + Buzzer

Bluetooth can also trigger sound.

Example:

BEEP

↓

Bluetooth Receive

↓

Logic

↓

Buzzer

Bluetooth supplies information.

The buzzer supplies the sound.


Bluetooth + Variables

Variables become useful when a received value will be reused.

Conceptually:

Bluetooth Receive

↓

Variable

↓

Logic

↓

Display

↓

Output

Variables help keep programs organized as projects become more complex.


Bluetooth + Text Processing

Received messages can also be treated as text.

Examples:

“Hello”

“Temperature:25”

"READY"

Text blocks can then:

  • Compare text
  • Search text
  • Modify text
  • Extract information

Bluetooth Receive vs Bluetooth Send

Bluetooth SendBluetooth Receive
Information leaves D1 R32Information enters D1 R32
D1 R32 → DeviceDevice → D1 R32
Sends informationReceives information
Outputs communicationInputs communication

Creating Two-Way Communication

Once Send and Receive are understood separately, they can be combined.

Conceptually:

Remote Device

↓

Command

↓

D1 R32 Receives

↓

Process

↓

Action

↓

Send Response

↓

Remote Device


Example

STATUS

↓

D1 R32 receives request

↓

Reads sensor

↓

Sends sensor information back


This creates:

COMMAND

↓

PROCESS

↓

RESPONSE


Always Observe First

Before controlling hardware:

  1. Receive the information.
  2. Send it to Serial.
  3. Observe it.
  4. Understand it.
  5. Compare it.
  6. Act on it.

Learning Pattern

RECEIVE

↓

REPORT

↓

OBSERVE

↓

INTERPRET

↓

COMPARE

↓

ACT

This keeps debugging simple and consistent with every other Clu-Blocks communication lesson.


Quick Guide for Students

Want to receive Bluetooth information?

Use:

Bluetooth Receive


What should I do first?

Receive

↓

Serial Monitor


Can I store the information?

Receive

↓

Variable


Can I control an LED?

Receive

↓

Compare

↓

LED


Can I move a servo?

Receive

↓

Logic

↓

Servo


Can I send information back?

Receive

↓

Process

↓

Bluetooth Send


Key Vocabulary

TermDefinition
BluetoothWireless communication technology
ReceiveObtain information from another device
MessageInformation sent between devices
CommandA message intended to trigger an action
VariableStorage location for information
LogicDecision-making process
ControlDetermines program actions
Serial MonitorTool used to view received data
MAC AddressUnique Bluetooth device identifier
Two-Way CommunicationDevices both send and receive information

Summary

In this lesson, you learned how Bluetooth Receive provides a wireless input channel for the D1 R32.

You explored how to:

 Receive Bluetooth messages

 Observe received information

 Store data in variables

 Compare commands

 Control outputs

 Display received information

 Build remote-control systems

 Create two-way communication projects

Bluetooth communication allows a D1 R32 to receive wireless information from phones, tablets, computers, and other devices. By combining Bluetooth, Logic, and Control blocks, students can create interactive wireless projects ranging from simple LED controllers to sophisticated robotic systems.


Key Takeaway

 Bluetooth Receive turns the D1 R32 into a wireless listener. Another device sends information, and the D1 R32 can observe it, interpret it, and act on it.

By learning to receive, verify, compare, and respond to Bluetooth messages, students can build wireless remote controls, interactive displays, smart robotics systems, and complete two-way communication projects.