Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Strings & Characters Primer

Strings & Characters Primer

Characters Inside Strings

Each string is a sequence of characters, where each character is defined by a code number. For example, the string “ABC 123” is stored as a sequence of numbers: 65 65 66 67 32 49 50 51 66 49 50 51. These numbers are called ASCII codes. ASCII stands for American Standard Code for Information Exchange. 

  • Open the ASCII chart at this link.
  • Find the Dec ASCII codes for upper-case A, B, and Z. 
  • Find the Dec ASCII codes for lower-case a through z.
  • Find the Dec ASCII codes for digits.

You can use Makecode blocks to return the ASCII code of a character, and also to return the character for a given ASCII code. Let’s try that!

Example project: chars_in_strings_intro

  • Enter and name chars_in_strings_intro.
  • Click the Download button.

  • Check the results in the serial terminal.
  • Verify that it displays a message that the ASCII code for A is 65, and the character with the ASCII code 66 is B.
  • Try some of your own characters and ASCII codes.

How chars_in_strings_intro Works

The block serial write line (“n = ASCII code for A”) displays a heading to help give context to the messages below it. 

The block char code from (“ ”) at () returns the ASCII code of a string that contains a single character. The ASCII code for the character A is 65. So, char code from (“A”) at (0) returns 65, and n = char code from (“A”) at (0) stores the value 65 in the variable n. 

After that, serial write line (join(“n = “)(n)) displays “n =”, followed by the value of n, which is 65. Lastly, the serial new line just prints an empty line.

After that empty line, serial write line (“c = character with ASCII code 66”) prints another heading. 

The text from char code () block accepts an ASCII code, and returns that ASCII code’s character. So, c = text from char code (66) stores the character B in a variable named c. 

Since c now stores the character B, serial write line (“c =”, c) prints c = B.


Printer-friendly version

Leave a Comment Cancel reply

Try This: Display with Variable Labels
Prev
Try This: Print Alphabets
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress