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

Let there be light!

Now we have everything we need to know to start building our project, let's start by writing the code:

int sensorPin = A0;            // select the input pin for the ldr 
unsigned int sensorValue = 0;  // variable to store the value coming from the ldr 
void setup() 
  pinMode(13, OUTPUT); 
  //Start Serial port 
  Serial.begin(9600);        // start serial for output - for testing 
void loop() 
  // read the value from the ldr: 
  sensorValue = analogRead(sensorPin);      
       digitalWrite(13, HIGH);   // set the LED on 
  else digitalWrite(13, LOW);   // set the LED off 

We start by storing the pin numbers in variables, so that it doesn't become confusing, and then initialize our LED pins for output.

The code consists of a if statement that checks the value of sensorValue. If the values stored in it is less than 400, meaning that...