Reader small image

You're reading from  Practical Arduino Robotics

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804613177
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Lukas Kaul
Lukas Kaul
author image
Lukas Kaul

Lukas Kaul is a robotics Research Scientist, currently working at the Toyota Research Institute in Silicon Valley, where he develops mobile manipulation technologies to support people in their homes and in their workplace. Throughout his career he has worked on projects as diverse as humanoid robots, aerial robots and mobile manipulation systems. A maker at heart, Lukas has been using Arduino technology extensively for more than a decade in countless side-projects, ranging from mapping systems to self-balancing robots. Lukas is passionate about teaching robotics with Arduino to inspire and empower anyone who wants to enter the exciting field of robotics. He holds a PhD degree from the Karlsruhe Institute of Technology, Germany.
Read more about Lukas Kaul

Right arrow

The general structure of an Arduino robot program

We have already gotten to know the general structure of an Arduino program, consisting of three main parts:

  • #include statements and declarations of global variables at the top.
  • The setup() function with all the necessary one-time initializations. It is called automatically at the start of the program execution.
  • The loop() function, which is executed in an infinite loop right after the setup() function has finished.

We can define many more functions that we can use inside the setup() and the loop() functions. This helps to keep these two main functions concise and readable, and it makes our program easier to maintain and modify. We usually write these functions at the end of the program, underneath the loop() function. An example of this is the mcp_read_channel() function that we developed in Chapter 2, Making Robots Perceive the World with Sensors.

This general structure is the same for every Arduino program...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Arduino Robotics
Published in: Mar 2023Publisher: PacktISBN-13: 9781804613177

Author (1)

author image
Lukas Kaul

Lukas Kaul is a robotics Research Scientist, currently working at the Toyota Research Institute in Silicon Valley, where he develops mobile manipulation technologies to support people in their homes and in their workplace. Throughout his career he has worked on projects as diverse as humanoid robots, aerial robots and mobile manipulation systems. A maker at heart, Lukas has been using Arduino technology extensively for more than a decade in countless side-projects, ranging from mapping systems to self-balancing robots. Lukas is passionate about teaching robotics with Arduino to inspire and empower anyone who wants to enter the exciting field of robotics. He holds a PhD degree from the Karlsruhe Institute of Technology, Germany.
Read more about Lukas Kaul