CxD Archive
Code: Robotics
Code: Robotics
  • Code Introduction
  • TUTORIALS
    • A. Meet Your Robot
      • A-1 Circuit Board
      • A-2 Motors and Wheels
      • A-3 Other Components
    • B. Hello World Test
      • B-1 Arduino Code Editor
      • B-2 New App Template
      • B-3 Global Variable
      • B-4 Setup Function
      • B-5 Loop Function
      • B-6 Upload App to Robot
      • B-7 Add Sound
      • B-8 Use Button
    • C. Driving and Turning
      • C-1 Driving
      • C-2 Turns (Pivoting)
      • C-3 Test Wheel Encoders
      • C-4 Drive for Specific Distance
      • C-5 Pivot By Specific Angle
      • C-6 Drive Straight Continuously
    • D. Detect Objects in Path
      • D-1 Test Mechanical Bumpers
      • D-2 Detect Collisions
      • D-3 Test Ultrasonic Sensor
      • D-4 Avoid Collisions
    • E. Detect Lines on Surface
      • E-1 Test IR Line Sensors
      • E-2 Follow Line
      • E-3 Avoid Line
      • E-4 Count Lines Crossed
      • E-5 Follow and Count Lines
    • F. Detect Other Conditions
      • F-1 Detect Surface Drop-Off
      • F-2 Test Accelerometer
      • F-3 Detect If Upside-Down
      • F-4 Detect If Bumped
  • REFERENCES
    • Arduino Language
    • Arduino Code Editor
      • Create New App
      • Save and Rename App
      • Include RedBot Library
      • Verify App Code
      • Upload App to Robot
      • Download Copy of App
      • Use Serial Monitor to View Data
      • Robot Demo App Template
    • Physical Inputs
      • Push Button (D12)
      • Mechanical Bumpers
      • IR Line Sensors
      • Wheel Encoders
      • Accelerometer
      • Ultrasonic Sensor *
    • Physical Outputs
      • LED Light (D13)
      • Speaker (Buzzer)
      • Motors
    • Robot Behaviors
      • Producing Alerts
      • Driving
      • Turning
      • Detecting Objects
      • Detecting Lines
      • Detecting Other Conditions
    • Navigation Modes
      • Distance Navigation
      • Line Counting Navigation
      • Line Following + Counting Navigation
      • Autonomous Navigation
  • LINKS
    • Robotics Project Guidebook
    • Arduino Create Web Editor
    • Arduino Language Reference
    • RedBot Experiment Guide
  • ELEGOO Experiments
    • Getting the Arduino IDE
    • Starting with the `techCar` Template
    • Template Code for techCar.ino
    • Template Experiments
    • Reinstall the Original Remote App Functionality, If Needed
Powered by GitBook
On this page
  • Tutorial Goals
  • Arduino Programming Language
  • What is a Hello World app?
Export as PDF
  1. TUTORIALS

B. Hello World Test

PreviousA-3 Other ComponentsNextB-1 Arduino Code Editor

Last updated 6 years ago

In this second tutorial, you'll program a "Hello World" app for your robot by using its LED light, speaker, and push button.

ALTERNATIVE TUTORIALS: Instead of completing these tutorials, your teacher might instruct your team to complete the . If so, you should complete all the experiments except Experiment 9 (Remote Control).

Afterwards, if your robot has an ultrasonic sensor, be sure to also complete these tutorials for that sensor: and

Tutorial Goals

The goals of this tutorial are to help you:

  • Understand how to use the Arduino programming language to code apps for your robot

  • Program a Hello World app that controls your robot's LED light, speaker, and push button

Arduino Programming Language

The RedBot robot runs apps written in a programming language called . The Arduino language is designed to make it easier to write programs for microcontrollers. Many electronic kits and robotics kits use Arduino for programming.

Arduino is actually a code library written in another computer language called (similar to how jQuery is a code library written in JavaScript). If and when necessary, your Arduino program can also incorporate code written directly in C++.

An Arduino program (or app) is also referred to as a sketch because the Arduino language is designed to allow you to quickly create a program — just like a sketch is a quick drawing.

These tutorials will introduce you to some of the basics of programming with Arduino. For additional help, the is useful for learning more about the structure and syntax of Arduino code.

What is a Hello World app?

When learning a new programming language, the first step that many people take is to create what is called a program. Traditionally, this program simply displays the text "Hello World" on the screen and only requires a few lines of code. The purpose is to demonstrate that you can create a simple yet functional program in the new coding language. It's a first step before creating more complex programs.

However, your robot does not have a built-in screen. The good news is your RedBot circuit board does have a built-in green LED light (D13) that can be controlled by your robot's app. So you'll first program a simple app that makes the built-in LED blink on and off repeatedly, as a way of saying "Hello World."

After that you'll modify the app to use the robot's speaker to produce a "beep" sound when the LED light blinks. Then you'll modify the app to detect when the built-in button (D12) on the circuit board is pressed, in order to make the LED blink and the speaker beep. Once all that is done, you'll start programming apps to make your robot drive around.

SparkFun Experiment Guide for RedBot
D-3 Test Ultrasonic Sensor
D-4 Avoid Collisions
Arduino
C++
Arduino Programming Language Reference
"Hello World"