Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Arduino Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
Arduino Essentials

Arduino Essentials

By : Perea
5 (5)
close
close
Arduino Essentials

Arduino Essentials

5 (5)
By: Perea

Overview of this book

If you are a hobbyist who wants to develop projects based on Arduino as the main microcontroller platform or an engineer interested in finding out what the Arduino platform offers, then this book is ideal for you. Some prior knowledge of the C programming language is required.
Table of Contents (12 chapters)
close
close
11
Index

Calibrating sensors serially


In Chapter 6, Analog Inputs to Feel between All and Nothing, I promised you that I'd show you how we can use a serial communication to calibrate the analog sensors you could connect to your projects, in particular in the ambient light meter and the motor speed control projects.

The time has now come to revisit these projects and finally unveil how we got the correct output range for the mapping we made in these projects.

If you remember, we used the following circuit for the ambient light meter as shown in the following image:

Ambient light meter circuit schematic

In the sketch, we had to read the photocell value and map it to a four-state output range with the following lines of code:

…
void loop(){
  // Read the sensor and convert the value to
  // one of the four states we will use
  value = analogRead(photocell);
  state = map(value,0, 200, 1, 4);
  // acts depending on the obtained states
  switch(state){
      case 1:
...

At that time, I didn't tell you how I...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY