Book Image

Arduino for Kids

By : Priya Kuber, Rishi Gaurav Bhatnagar, Vijay Varada
Book Image

Arduino for Kids

By: Priya Kuber, Rishi Gaurav Bhatnagar, Vijay Varada

Overview of this book

The mission of this book is to integrate technology with the tools that children already use for crafts so that they feel that the technology is an extension of their playtime. We use coding, sensors, and micro-controllers integrated with art and craft supplies, origami, and Playdough. There are 10 fun-filled chapters that talk to children directly, and give clear instructions for non-technical parents too. We use Arduino as the controller of choice due to its easy availability and large community. By the end of the book, children will comfortably be able to set up their Arduino, read and understand code, manipulate code, and ultimately write their own code for projects. They will also be able to use basic sensors and know how components connect to each other. All the learning takes place with lots of colorful pictures and the circuits are neatly presented using wiring.
Table of Contents (18 chapters)
Arduino for Kids
About the Authors
About the Reviewers
Customer Feedback

The working

When the button isn't pressed, there is no connection between the two legs of the button; it will input 0V to the Arduino since the pin of the button is connected to ground through the pull-down resistor. If you recall what we learned about logic states, the Arduino should read a LOW or binary 0 in this case.

Then the button is pressed and the connection is closed; this makes a connection between its two legs, thus connecting 5V to the Arduino's I/O pin, and we read a HIGH or binary 1.

Let's walk through this code, line by line, so that you can understand what each line does:

int state = 0; 

This initializes a variable of an integer type and puts the value of 0 in it.

This is also called initializing a variable. In our case, this variable shall store the value of the state of our button. Values are assigned to variables using = ; hence, this is also called an assignment operator:

void setup() { 
  // initialize digital I/O pins 
  pinMode(2, INPUT);