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
  • Create New App
  • Arduino Create (Web Editor)
  • Arduino IDE (Desktop Editor)
  • Starter Code in New App
  • Add Comment Block to Identify App
Export as PDF
  1. REFERENCES
  2. Arduino Code Editor

Create New App

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.

This guidebook will primarily use the term "app" but just keep in mind that program, app, and sketch all mean the same thing in Arduino: a set of coded software instructions to control the operation of a computing device (which is your robot, in this case).

Create New App

Arduino Create (Web Editor)

  1. If necessary, click the Sketchbook menu link in the left navigation panel to display the Sketchbook menu options in the middle panel.

  2. Click the New Sketch button at the top of the middle panel.

Arduino IDE (Desktop Editor)

Under the File menu, select "New" – or you can click the New icon (looks like a document) at the top of an existing code editor window.

Starter Code in New App

If you're using the Arduino Create web editor, your new app template will probably look like this:

/*



*/



void setup() {

    

}



void loop() {

    

}

If you're using the Arduino IDE desktop editor, your new app template will probably look like this:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

In both cases, the starter code contains a setup() function and a loop() function. You'll need to add code within these functions to complete your app.

Add Comment Block to Identify App

It is recommended to add a comment block at the beginning of your code to list a title for your app and any other information that might be helpful to you or anyone reviewing the program code.

A blank comment block is created with slashes and asterisks like this:

/*

*/

In between the asterisks, you can list as many lines of comments as you want or need. This would be a good place to list your app's name and perhaps describe its purpose. You could also include other information, such as your team information, your teacher's name and class period, etc.

Ask your teacher if there is specific information that should be listed in this block comment.

For example, your block comment might look like this:

/*
Hello World App
Team 3 - Destiny, Katya, Lucas, Miguel
Ms. Hopper - Period 2
*/

PreviousArduino Code EditorNextSave and Rename App

Last updated 6 years ago