Table of Contents
Preface vii
1 Sensors 1
Project 1 Photoresistor to Measure Light 3
Parts 4
Build It 5
Discussion: Photoresistors 6
Interactive Sensor Control 7
Going Forward 7
2 Basic Sensors 9
Project 2 A Simple Switch 9
Parts 9
Build It 10
Troubleshooting 11
An LED Needs a Resistor 12
Project 3 Buzzer Volume Control 12
Parts 13
Build It 13
Troubleshooting. 14
Project 4 Hall Effect 14
Parts 16
Build it 15
Troubleshooting 16
Project 5 Firefly 17
Integrated Circuits 17
555 Timer IC 18
Light Up an LED When It's Bright 19
Light to Darkness 21
Transistors 22
Fading an LED 24
555 Fading Blink 25
Capacitors 28
Firefly 29
3 Sensors and Arduino 33
Project 6 Momentary Push-Button and Pull-Up Resistors 34
Parts 34
Build It 35
Run the Code 35
Pull-Up Resistors and Arduino 37
Project 7 Infrared Proximity to Detect Objects 40
Parts 41
Build It 42
Project 8 Rotation (Pot) 43
Parts 45
Build It 46
Run the Code 46
Project 9 Photoresistor to Measure Light 47
Parts 47
Build It 48
Run the Code 49
Project 10 FlexiForce to Measure Pressure 49
Parts 50
Build It 50
Run the Code 51
Project 11 Measuring Temperature (LM35) 52
Parts 53
Build It 53
Run the Code 55
Project 12 Ultrasonic Distance Measuring (HC-SR04) 56
Parts 57
Build It 57
Run the Code 58
Conclusion 61
4 Sensors and the Raspberry Pi 63
Project 13 Momentary Push Button 64
Parts 64
Build It 64
Run the Button Code 66
Troubleshooting 67
Hello, Python World 68
Project 14 Blink an LED with Python 69
Parts 69
Build the LED Blink Project 69
Run the Code 70
Project 15 Adjustable Infrared Switch 73
Parts 73
Build the IR Switch Project 73
Run the Code 74
Voltage Divider 76
Analog Resistance Sensors 77
Project 16 Potentiometer to Measure Rotation 77
Parts 78
Build It 78
Install SpiDev 78
Allow SPI Without root 79
Run the Code 80
Project 17 Photoresistor 82
Parts 82
Build It 83
Run the Code 83
Playing with Resistance Numbers 83
Project 18 FlexiForce 85
Parts 85
Build It 85
Run the Code 86
Project 19 Temperature Measurements (LM35) 86
Parts 86
Build It 86
Run the Code 87
Project 20 Ultrasonic Distance 89
Parts 89
Build It 90
Run the Code 90
Real Time or Fast? 92
A Troubleshooting Tactics 95
B Arduino IDE Setup 97
C Setting Up Raspberry Pi 101
D Eill of Materials 117
Index 123