Text
Text
Computers work with numbers, but people communicate using words.
The Text category allows programs to create messages, combine words with data, compare information, format sensor readings, and communicate with users and other devices.
Examples:
Hello World!, Temperature: 25°C, Distance: 42 cm, Bluetooth Connected
Without Text: 23
With Text: Temperature: 23°C
Text helps transform raw data into meaningful information.
What Is Text?
A piece of text in programming is called a string.
Strings can contain:
- Letters
- Words
- Numbers
- Symbols
- Complete sentences
Examples:
“Hello”, “Clu-Bots”, “Temperature: 25°C”, "Ready"
Think of Text as your robot’s written voice. It allows the program to communicate with people using words and messages.
Why Is Text Important?
Text appears everywhere in programming.
LCD Display - Hello World!
OLED Display - Temperature: 25°C
Serial Monitor- Distance: 42 cm
Bluetooth Message - Robot Ready
ESP-NOW Message - START
Text Category
[INSERT CATEGORY IMAGE HERE: Text]
Figure 8.1 – Blocks available in the Text category.
The Text category allows a program to:
Create text
Combine text
Convert values
Compare strings
Extract characters
Replace text
Split text
Format messages
Prepare information for displays and communication systems
Text Learning Model
CREATE
↓
COMBINE
↓
CONVERT
↓
EXAMINE
↓
MODIFY
↓
FORMAT
Text Block Quick Reference
| Block | Purpose | Main Idea |
|---|---|---|
| Text String | Create text | Create a message |
| Join Text | Combine text | Text A + Text B |
| ASCII → Character | Convert number to character | 65 → A |
| Character → ASCII | Convert character to number | A → 65 |
| toString | Convert value to text | 23 → "23" |
| Length | Count characters | How long is this text? |
| Compare | Match strings | Compare text |
| Get Character | Extract a character | Position → Character |
| Get Range | Extract part of a string | Start → End |
| Random Character | Select random character | Surprise letter |
| Encode | Convert text encoding | Text conversion |
| Character Index | Character position operations | Character location |
| Concatenate Sequence | Join list items | List → String |
| Replace | Replace text | Find → Replace |
| Split | Break text apart | String → Parts |
| Strip | Remove spaces | Clean text |
| Format String | Create readable messages | Value → Sentence |
| Execution Result | Process string operation | Evaluate expression |
Creating Text
[INSERT BLOCK IMAGE HERE: Text String]
The simplest text block creates a string.
Example:
"Hello Clu-Bots"
Conceptually:
Message
↓
Text String
Joining Text
[INSERT BLOCK IMAGE HERE: Join Text]
The Join block combines two pieces of text.
Example:
"Hello"
and
"Clu-Bots"
become:
HelloClu-Bots
Conceptually:
Text A
+
Text B
↓
Combined Text
Real Example
"Temperature: "
+
23
↓
Temperature: 23
Converting Values into Text
[INSERT BLOCK IMAGE HERE: toString]
Programs often need to combine numbers with words.
Example:
23
↓
"23"
Conceptually:
Value
↓
toString
↓
Text
Finding the Length of Text
[INSERT BLOCK IMAGE HERE: Get Length]
Example:
"Clu-Bots"
Length:
8
Students can think of this block as asking:
How many characters are in this text?
Comparing Text
[INSERT BLOCK IMAGE HERE: Text Comparison]
Programs often need to check whether messages match.
Comparison Options
| Option | Meaning |
|---|---|
| equals | Exact match |
| startsWith | Begins with |
| endsWith | Ends with |
Examples:
"Clu-Bots" equals "Clu-Bots"
True
"Clu-Bots" startsWith "Clu"
True
"Clu-Bots" endsWith "Bots"
True
Working with Individual Characters
Example:
Clu-Bots
Positions:
0 1 2 3 4 5 6 7
C l u - B o t s
Get One Character
[INSERT BLOCK IMAGE HERE: Get Character]
Example:
"Clu-Bots"
Position:
0
Result:
C
Get Part of a String
[INSERT BLOCK IMAGE HERE: Get Range]
Example:
"Clu-Bots"
From:
0
To:
2
Returns:
Clu
Random Character
[INSERT BLOCK IMAGE HERE: Random Character]
Example:
"Clu-Bots"
may return:
C
or - o
or - s
Useful for:
- Games
- Password generators
- Puzzles
- Random word activities
ASCII and Characters
[INSERT BLOCK IMAGE HERE: ASCII to Character]
[INSERT BLOCK IMAGE HERE: Character to ASCII]
Computers store characters using numbers.
This is called ASCII.
Common ASCII Values
| Character | ASCII |
|---|---|
| A | 65 |
| B | 66 |
| C | 67 |
| a | 97 |
| b | 98 |
| c | 99 |
| 0 | 48 |
| 1 | 49 |
| Space | 32 |
Concept:
ASCII
⇄
Character
Example:
65
↓
A
Encoding Text
[INSERT BLOCK IMAGE HERE: Encode String]
Some communication systems store text using different encoding formats.
Available Encoding Types
| Encoding | Description |
|---|---|
| ASCII | Standard English text |
| UTF-8 | Most common encoding |
| UTF-16 | Extended Unicode |
| UTF-32 | Large Unicode format |
| GB2312 | Simplified Chinese |
| GBK | Extended Chinese |
For most projects, use UTF-8.
Character Index Operations
[INSERT BLOCK IMAGE HERE: Character Index]
These blocks work with character positions inside strings.
Example:
"Hello,Clu-Bots"
↓
Position operations
↓
Character Location
Joining Lists into Text
[INSERT BLOCK IMAGE HERE: Concatenate Sequence]
Example List:
[A, B, C]
↓
Join
↓
ABC
Concept:
List
↓
Join
↓
One String
Replacing Text
[INSERT BLOCK IMAGE HERE: Replace Text]
Example:
Hello Clu-Bots
Replace:
Clu-Bots
With:
Clu-Block
Result:
Hello Clu-Block
Splitting Text
[INSERT BLOCK IMAGE HERE: Split Text]
Example:
A,B,C
↓
Split
↓
A
B
C
Concept:
One String
↓
Split
↓
Many Parts
Removing Spaces
[INSERT BLOCK IMAGE HERE: Strip Text]
Strip Options
| Option | Effect |
|---|---|
| Both | Remove spaces from both ends |
| Left | Remove spaces from the beginning |
| Right | Remove spaces from the end |
Example:
" Hello "
↓
Strip Both
↓
Hello
Formatting Messages
[INSERT BLOCK IMAGE HERE: Format String]
Formatting combines values and text.
Example:
Random Number: []
with:
57
Results in:
Random Number: 57
Other examples:
Temperature: 23°C
Distance: 42 cm
Battery: 85%
This is one of the most useful Text blocks in the entire curriculum.
String Execution Result
[INSERT BLOCK IMAGE HERE: Get String Execution Result]
This block performs the string execution-result operation available in Clu-Blocks Pro.
Example:
input("1+2*3")
At this stage students should think of it as:
Input String
↓
Process
↓
Result
Advanced uses can be explored later.
Text and Other Categories
Text becomes more powerful when combined with other categories.
Sensors
Sensor
↓
Value
↓
Text
↓
Serial
LCD
Text
↓
LCD
OLED
Text
↓
OLED
Bluetooth
Text
↓
Bluetooth
ESP-NOW
Text
↓
ESP-NOW
Most Important Beginner Pattern
Sensor
↓
Value
↓
toString
↓
Join / Format
↓
Serial Monitor
Without formatting:
23
With formatting:
Temperature: 23°C
This is one of the most important ideas students learn in programming.
Quick Guide for Students
Need to create a message?
Use:
Text String
Need to combine text?
Use:
Join
Need to convert a number into text?
Use:
toString
Need to compare words?
Use:
Compare
Need one character?
Use:
Get Character
Need to replace text?
Use:
Replace
Need a readable message?
Use:
Format String
Quick Reference
| Group | Main Idea |
|---|---|
| Create | Make text |
| Join | Combine text |
| Convert | Values ↔ Text |
| Length | Count characters |
| Compare | Match text |
| Character | Get one letter |
| Range | Get part of a word |
| Random | Select random character |
| Encode | Transform text |
| Replace | Change text |
| Split | Break text apart |
| Strip | Remove spaces |
| Format | Create readable messages |
| Execute | Process string expressions |
Summary
In this lesson, you learned how Text blocks allow programs to create, manipulate, and communicate information using words and characters.
You explored:
Creating strings
Joining text
Converting values
Extracting characters
Comparing text
Replacing text
Splitting text
Formatting messages
Combining Text with sensors, displays, Bluetooth, ESP-NOW, and Serial communication
Key Takeaway
Text gives your program a written voice. It transforms raw data into meaningful information that people can read, understand, and use.
By learning to create, combine, examine, modify, and format text, students develop one of the most important skills in programming: making information understandable.
