Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Sensors

You're reading from   Raspberry Pi Sensors Integrate sensors into your Raspberry Pi projects and let your powerful microcomputer interact with the physical world

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784393618
Length 192 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Rushi Gajjar Rushi Gajjar
Author Profile Icon Rushi Gajjar
Rushi Gajjar
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Meeting Your Buddy – the Raspberry Pi FREE CHAPTER 2. Meeting the World of Electronics 3. Measuring Distance Using Ultrasonic Sensors 4. Monitoring the Atmosphere Using Sensors 5. Using an ADC to Interface any Analog Sensor with the Raspberry Pi 6. Uploading Data Online – Spreadsheets, Mobile, and E-mails 7. Creating an Image Sensor Using a Camera and OpenCV A. Shopping List Index

Practice makes you perfect

This section includes some practice problems, which should be exercised with shell, C, and Python. The reason behind this practice is that it will make you stronger in understanding the problems and logic of programs, which can really help you to easily make the sensor project. This practice will not cover or give you the idea of entire language or script, but will make you comfortable enough to understand the codes used in the next chapters.

I advise you to connect the Raspberry Pi through an Ethernet cable with your PC, and use the methods stated in the preceding sections to execute the programs. You can take help of the Internet (www.cprogramming.com/quiz/) to understand the logic and the syntax. The problem statements shown here should be attempted in all three languages/scripts, which will give you enough idea to work with scripts and languages:

  • Write a program to get all Armstrong numbers below 1000. Note that among three digit numbers, an Armstrong number is equal to the sum of the cubes of its digits. For example, 153 is an Armstrong number because 153 = 13+ 53+33.
  • Convert the temperature value from degrees Celsius to degrees Fahrenheit and vice versa. Ask user to get the value and decide whether they are entering it in Celsius or Fahrenheit. Show a warning message if the temperature is above 38 degrees Celsius or 100 degrees Fahrenheit.
  • Create a calculator that has all the basic functionalities, such as addition, subtraction, division, and multiplication. Ask the user to select the function they want. Show an error if they divide anything by zero.
  • Get a time value from the clock, attach to a Time is string, and display the current time, for example, Time is 17-Oct-14 10:18:22AM.

The skills acquired by performing these exercises will allow you to better understand the projects in the upcoming chapters. You can expect an easy programming level in upcoming chapters. These chapters will focus more on Python and C programs. Hence, more practice on programs will help you gain a better understanding of the language and increase logical thinking.

You have been reading a chapter from
Raspberry Pi Sensors
Published in: Apr 2015
Publisher:
ISBN-13: 9781784393618
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime