Admin مدير المنتدى
عدد المساهمات : 18996 التقييم : 35494 تاريخ التسجيل : 01/07/2009 الدولة : مصر العمل : مدير منتدى هندسة الإنتاج والتصميم الميكانيكى
| موضوع: كتاب Make: Action - Movement, Light, and Sound with Arduino and Raspberry Pi الخميس 22 فبراير 2024, 2:25 am | |
|
أخواني في الله أحضرت لكم كتاب Make: Action - Movement, Light, and Sound with Arduino and Raspberry Pi Simon Monk
و المحتوى كما يلي :
Table of Contents 1. Introduction . 1 Arduino and Pi . 1 Raspberry Pi . 1 Arduino 3 Choosing a Device: Arduino or Pi? 4 Alternatives 5 Summary 6 2. Arduino . 9 What Is an Arduino? 9 Installing the Arduino IDE . 11 Uploading a Sketch . 13 The Book Code 14 Programming Guide . 14 Setup and Loop . 15 Variables . 15 Digital Outputs . 16 Digital Inputs . 16 Analog Inputs 18 Analog Outputs . 19 iiiIf/Else 20 Loops 21 Functions 22 Summary . 23 3. Raspberry Pi . 25 What Is a Raspberry Pi? 25 Setting Up Your Raspberry Pi 27 Preparing a MicroSD Card with NOOBS 28 Setting Up SSH . 29 SSH on a Windows Computer . 31 SSH on Mac or Linux 32 The Linux Command Line . 32 The Book Code 34 Programming Guide . 35 Hello, World 35 Tabs and Indents 35 Variables . 36 if, while, etc . 36 The RPi.GPIO Library 37 The GPIO Header . 37 Digital Outputs . 38 Digital Inputs . 39 Analog Outputs . 39 Summary . 39 4. Quickstart . 41 Solderless Breadboard . 41 How a Breadboard Works . 43 Connecting a Breadboard to the Arduino 43 Connecting a Breadboard to the Raspberry Pi 44 Downloading the Software 45 iv Make: ActionExperiment: Controlling an LED 46 Parts List 46 Breadboard Layout . 46 Arduino Connections . 47 Arduino Software . 48 Arduino Experimentation . 49 Raspberry Pi Connections . 49 Raspberry Pi Software . 51 Raspberry Pi Experimentation . 52 Comparing the Code 52 Experiment: Controlling a Motor . 53 Parts List 53 Breadboard Layout . 54 Experimenting Without Arduino or Raspberry Pi . 55 Arduino Connections . 56 Arduino Experimentation . 57 Raspberry Pi Connections . 57 Raspberry Pi Experimentation . 58 Summary . 58 5. Basic Electronics 59 Current, Voltage, and Resistance . 59 Current . 59 Voltage . 60 Ground . 61 Resistance 61 Power . 62 Common Components 63 Resistors 63 Transistors 64 Diodes . 71 LEDs 71 Table of Contents vCapacitors 72 Integrated Circuits 72 The Ins and Outs of Connections . 73 Digital Outputs . 73 Digital Inputs . 73 Analog Inputs 73 Analog Outputs . 74 Serial Communication 74 Summary . 74 6. LEDs . 75 Regular LEDs 76 Current Limiting 76 Project: Traffic Signal 78 Parts List 79 Design . 80 Arduino Connections . 80 Arduino Software . 81 Raspberry Pi Connections . 82 Raspberry Pi Software . 83 PWM and LEDs 84 RGB LEDs . 85 Experiment: Mixing Colors . 86 Hardware . 86 Parts List 88 Arduino Connections . 88 Arduino Software . 89 Arduino Experimentation . 90 Raspberry Pi Connections . 90 Raspberry Pi Software . 91 Raspberry Pi Experimentation . 93 Summary . 93 vi Make: Action7. Motors, Pumps, and Actuators . 95 Controlling Speed (PWM) 96 Experiment: Controlling the Speed of a DC Motor 96 Hardware . 96 Arduino Connections . 97 Arduino Software . 98 Arduino Experimentation 100 Raspberry Pi Connections 100 Raspberry Pi Software . 101 Raspberry Pi Experimentation 102 Controlling DC Motors with a Relay . 102 Switching a Relay with Arduino or Raspberry Pi . 103 Relay Modules . 105 Experiment: Controlling a DC Motor with a Relay Module 106 Parts List 106 Wiring . 106 Arduino Software 107 Raspberry Pi Software . 108 Choosing a Motor 108 Torque 108 RPM . 109 Gears 110 Gearmotors . 110 Pumps . 110 Peristaltic Pumps 111 Velocity Pumps 112 Project: Arduino House Plant Waterer . 114 Design 114 Parts List 115 Construction 116 Software 118 Table of Contents viiUsing the Project 120 Linear Actuators . 120 Solenoids 122 Summary 123 8. Advanced Motor Control 125 H-Bridges 126 H-Bridge on a Chip . 128 Experiment: Control the Direction and Speed of a Motor 130 Parts List 131 Design 132 Breadboard Layout 133 Experimenting 135 Arduino Connections 136 Arduino Software 137 Arduino Experimentation 139 Connecting the Raspberry Pi . 140 Raspberry Pi Software . 141 Raspberry Pi Experimentation 142 Other H-Bridge ICs . 143 L298N . 143 TB6612FNG . 147 H-Bridge Modules 147 Project: Arduino Beverage Can Crusher . 149 Parts List 149 Wiring . 150 Mechanical Construction 151 Arduino Software 151 Summary . 152 9. Servomotors 153 Servomotors . 153 viii Make: ActionControlling a Servo 154 Experiment: Control the Position of a Servomotor . 155 Hardware . 156 Parts List 156 Connecting the Arduino . 157 Arduino Software 158 Experimenting with Arduino . 159 Connecting the Raspberry Pi . 160 Raspberry Pi Software . 160 Experimenting with Raspberry Pi . 162 Project: Pepe, the Dancing Raspberry Pi Puppet . 162 Parts List 164 Design 164 Construction 165 Software 172 Using Pepe the Puppet 173 Summary 174 10. Stepper Motors . 175 Stepper Motors 176 Bipolar Stepper Motors . 176 Experiment: Controlling a Bipolar Stepper Motor 178 Parts List 179 Design 180 Arduino . 181 Arduino Connections 181 Arduino Software (the Hard Way) 183 Arduino Software (the Easy Way) . 185 Arduino Experimentation 186 Raspberry Pi . 187 Raspberry Pi Connections 187 Raspberry Pi Software . 188 Table of Contents ixRaspberry Pi Experimentation 190 Unipolar Stepper Motors . 190 Darlington Arrays 191 Experiment: Controlling a Unipolar Stepper Motor 192 Hardware . 193 Parts List 194 Arduino Connections 195 Raspberry Pi Connections 195 Software 196 Microstepping . 196 Experiment: Microstepping on Raspberry Pi . 197 Parts List 197 Raspberry Pi Connections 198 Software 198 Experimenting 200 Brushless DC Motors . 201 Summary 202 11. Heating and Cooling 203 Resistive Heaters . 203 Experiment: Resistor Heating . 203 Parts List 203 Construction 204 Experimenting 204 Project: Arduino Random Balloon Popper . 205 Parts List 206 Hardware . 206 Software 208 Using the Balloon Popper 209 Heating Elements 209 Power and Energy 210 From Power to Temperature Increase . 210 x Make: ActionBoiling Water 210 Peltier Elements 211 How Peltier Elements Work 211 Practical Considerations . 212 Project: Beverage Cooler . 215 Parts List 215 Construction 216 Using the Project 217 Summary 218 12. Control Loops 219 The Simple Thermostat . 219 Experiment: How Good Is On/Off Thermostatic Control? . 220 Parts List 221 Design 222 Breadboard Layout 223 Software 224 Experimenting 227 Hysteresis 228 PID Control 229 Proportional (P) 230 Integral (I) . 231 Derivative (D) 232 Tuning a PID Controller 232 Experiment: PID Thermostatic Control 233 Hardware . 234 Arduino Software 234 Arduino Experimentation 236 Connecting the Raspberry Pi . 240 Raspberry Pi Software . 241 Raspberry Pi Experimentation 245 Project: A Thermostatic Beverage Cooler 246 Table of Contents xiHardware . 246 Parts List 246 Design 247 Construction 248 Arduino Software 250 Summary 254 13. Controlling AC 255 AC Switching in Theory . 256 What Is Alternating Current? . 256 Relays . 257 Optoisolator . 257 Zero-Crossing Optoisolators and Triacs . 258 AC Switching in Practice 260 Relay Modules . 260 Solid State Relays (SSRs) . 262 The PowerSwitch Tail 263 Project: Raspberry Pi Timer Switch 263 Parts List 263 Construction 264 Software 265 Using the Project 266 Summary 266 14. Displays 267 LED Strips 267 Experiment: Controlling an RGB LED Strip Display . 268 Parts List 269 Arduino Connections 269 Arduino Software 270 Raspberry Pi Connections 271 Raspberry Pi Software . 273 xii Make: ActionI2C OLED Displays 275 Experiment: Using an I2C Display Module with Raspberry Pi . 276 Parts List 276 Connections . 277 Software 277 Experimentation . 279 Project: Adding a Display to the Beverage Cooler Project 279 Parts List 280 Connections . 280 Software 281 Summary 282 15. Sound 283 Experiment: Unamplified Speaker and Arduino . 283 Parts List 284 Breadboard Layout 284 Arduino Software 285 Arduino Experimentation 286 Amplifiers . 286 Experiment: Playing Sound Files on an Arduino . 287 Parts List 287 Creating the Sound Data . 287 Arduino Code . 289 Arduino Experimentation 290 Connecting an Arduino to an Amplifier . 290 Playing Sound Files on Raspberry Pi 293 Project: Pepe the Puppet Gets a Voice . 293 Parts List 294 Breadboard Layout 295 Software 296 Using the Talking Puppet 298 Summary 298 Table of Contents xiii16. The Internet of Things 299 Raspberry Pi and Bottle 300 Project: A Raspberry Pi Web Switch . 301 Hardware . 301 Software 302 Using the Web Switch . 303 Arduino and Networks . 303 Project: Puppet Twitter Notifier . 305 Putting Pepe on the Internet . 306 IFTTT (If This Then That) 309 Using the Project 311 Summary 312 Appendix A. Parts 313 Appendix B. Raspberry Pi GPIO Pinout . 319 Index 321 Index Symbols != (not equal to) operator in C, 20 " " (quotation marks, double) in Python strings, 36 $ (dollar sign), Linux prompt, 32 && (and) operator in C, 21 ' ' (quotation marks, single) in Python strings, 36 // in C comments, 15 1-wire bus, 224, 241 2N3904 transistors, 71 2N7000 transistors, 71 400-point breadboards, 41 9g servomotors, 154 : (colon) in Python code, 36 <= (less than or equal to) operator in C, 20 == (equal to) operator in C, 17, 17 > (greater than) operator in C, 20 >= (greater than or equal to) operator in C, 20 {} (curly braces), enclosing code blocks in C, 17 || (or) operator in C, 21 Ω (omega), 61 A A (amperes or amps), 60 AC (alternating current), 255-266 dangers of high voltage, 255 defined, 256 project, Raspberry Pi timer switch, 263-266 parts list, 263 software, 265 using the project, 266 wiring diagram for, 264 switching in practice, 260 PowerSwitch Tail, 263 relay modules, 260 solid-state relays (SSRs), 262 switching in theory optoisolators, 257 relays, 257 zero-crossing optoisolators and TRIACs, 258 actual temperature, 220 actuators and sensors in control systems, 219 linear, 120, 149 Adafruit 16-Channel 12-bit PWM/Servo Driver, 162 code for, 172 Adafruit NeoPixel library, 270 Adafruit Trinket, 6 addressable LEDs, 267 power consumption, 270 alternating curent (see AC) amplifiers, 286 connecting an Arduino to, 290 amps (amperes), 60 321analog input and output analog inputs in Arduino, 18, 73 analog outputs, 74 analog outputs in Arduino, 19 analog outputs in Raspberry Pi, 39 analog input pins (Arduino Uno), 10 analogRead() function, 18 analogWrite() function, 19, 99 Arduino, 1, 3, 9-24 analog inputs, 73 analog outputs, 74 beverage can crusher project, 149-152 Arduino sketch for, 151 choosing, Raspberry Pi versus, 4 code examples from this book, 14 connecting a breadboard to, 43 connecting to an amplifier, 290 controlling a bipolar stepper motor, 181 Arduino connections, 181 Arduino sketches for, 183 experimenting with Arduino, 186 using Stepper library, 185 controlling a DC motor with a relay module, 107 controlling an LED with breadboard connections, 47 experimenting with delay functions, 49 sketch for, 48 controlling DC motor's speed (experiment) Arduino connections to the breadboard, 97 Arduino experimentation, 100 Arduino sketch for, 98 controlling motor's direction and speed Arduino experimentation, 139 Arduino sketch for, 137 connecting Arduino and H-bridge, 136 controlling position of a servomotor Arduino sketch for, 158 connecting Arduino to the servomotor, 157 experimenting with Arduino, 159 controlling RGB LED strip display Arduino connections, 269 Arduino software, 270 parts list, 269 digital inputs, 73 digital outputs, 73 H-bridge shields for, 148 house plant waterer project, 114-120 Arduino sketch for, 118 LED traffic signal project Arduino sketch for, 81 connections, 80 making network and Internet capable, 299 map() function, 253 networks and, 303 on/off thermostatic control experiment, 220-228 experimenting, 227 software, 224 PID thermostatic control experiment Arduino software, 234 experimenting with Arduino, 236 playing sound files on, 287-290 Arduino code, 289 experimenting with Arduino, 290 programming, 4 programming guide, 14 analog inputs, 18 analog outputs, 19 digital inputs, 16 digital outputs, 16 functions, 22 if/else statement, 20 loops, 21 setup() and loop() functions, 15 variables, 15 pulse-width modulation (PWM) on output pins, 85 random balloon popper poject, 205-209 sketch for, 208 RGB LED experiment Aduino experimentation, 90 Arduino connections, 88 Arduino sketch for, 89 serial communication, 74 shields, 4 specifications, 3 switching relays with, 103 thermostatic beverage cooler project, 246 Arduino software, 250 322 Indextour of Arduino Uno R3 board, 9 unamplified speaker with, 283-286 Arduino experimentation, 286 Arduino software, 285 breadboard layout, 284 uploading a sketch, 13 using OLED display with, 279-282 connections, 280 software, 281 using to control a motor breadboard connections, 56 experimenting with Arduino delay functions, 57 Arduino IDE installing, 11 installing libraries, 225 main window, 11 uploading a sketch, 13 Arduino Uno, 3 alternatives to, 5 pulse with modulation (PWM) on output pins, 85 Arduino Yun, 6 WiFi, 303 ATMega328, 10 Audacity, 287 exporting a sound clip, 288 recording a sound clip, 287 audio, 283 (see also sound) frequencies, 284 audio and video connector, Raspberry Pi, 26 Audio Encoder utility, 287 B balloon popper project, 205-209 hardware, 206 parts list, 206 software, 208 timing the balloon pop, 209 base (transistors), 64 BeagleBone Black versus Raspberry Pi 2, 6 beverage cooler (see cooler for beverages) bipolar stepper motors, 176 controlling, experiment in, 178-190 Arduino connections, 181 Arduino experimentation, 186 Arduino software, 183 design, 180 parts list, 179 Raspberry Pi connections, 187 Raspberry Pi experimentation, 190 Raspberry Pi software, 188 Raspberry Pi, using, 187 identifying stepper motor leads, 179 sequence of coil activations to rotate counterclockwise, 178 bipolar transistors, 65 Blink sketch (example) setup() and loop() functions, 15 uploading to Arduino board, 13 blink() function (example), 22 Bottle (web server framework), 300 HTML templates, 302 breadboards, 316 Arduino breadboard layout for bipolar stepper motor, 182 connecting to Arduino, 43 connecting to Raspberry Pi, 44 experimenting with and testing, 55 inner workings of, 43 layout for Arduino and speaker, 284 layout for Arduino traffic signal, 80 layout for balloon popper, 206 layout for controlling a motor, 54 Arduino connections, 56 Raspberry Pi connections, 57 layout for controlling an LED, 46 Arduino connections, 47 Raspberry Pi connections, 49 layout for controlling motor speed, 96 Arduino connections, 97 Raspberry Pi connections, 100 layout for houseplant watering project, 116 layout for on/off thermostat, 223 layout for Raspberry Pi PID thermostat, 240 layout for Raspberry Pi traffic signal, 82 layout for RGB LED experiment Arduino connections, 88 Raspberry Pi connections, 90 Index 323layout for standalone testing of H-bridge, 133 layout for talking puppet, 295 layout for thermostatic beverage cooler, 249 Raspberry Pi layout for stepper motor, 187 solderless, 41 brightness of LEDs, 77 controlling with PWM analog output, 84 Broadcom (BCM) names for pins, 51 Broadcom chips, 37 GPIO pin current, 62 C C language, 4 code to control an LED, comparing to Python, 52 comments, 15 comparison operators, 20 global and local variables, 23 indentation in code, 35 pointers, 236 programming for Photon, 304 can crusher project, 149-152 Arduino software, 151 mechanical construction, 151 parts list, 149 wiring, 150 capacitors, 72, 132, 314 for H-bridge IC circuit, 133 cd (change directory) command, 33 chips, 72 (see also integrated circuits) clockwise, motor turning, 134 cloud services, 299 code examples from this book downloading from GitHub, 14, 45 for Raspberry Pi, 34 collector (transistors), 64 colors of LEDs, 76 command line (Linux on Raspberry Pi), 32 command-line access to Raspberry Pi over your network, 29 common (COM) terminals, 103, 107 commutators, 96 comparison operators in C, 20 const keyword (in C), 16 Control connection, 55 control loops, 219-254 experiment, on/off thermostatic control, 220-228 breadboard layout, 223 design, 222 experimenting with Arduino, 227 parts list, 221 software, 224 experiment, PID thermostatic control, 233-245 Arduino experimentation, 236 Arduino software, 234 hardware, 234 Raspberry Pi connections, 240 Raspberry Pi experimentation, 245 Raspberry Pi software, 241 hysteresis, 228 project, thermostatic beverage cooler, 246-254 adding the temperature probe, 248 Arduino software, 250 attaching the cooling unit, 250 attaching the power socket, 250 constructing the breadboard, 249 design, 247 hardware, 246 parts list, 246 proportional-integral-derivative (PID) control, 229 derivative control, 232 integral control, 231 proportional control, 230 tuning a PID controller, 232 thermostat, simple, 219 control_pin variable, 52 cooler for beverages (project), 215-218 adding display to, 279-282 connections, 280 software, 281 construction, 216 parts list, 215 thermostatic beverage cooler, 246-254 thermostatic beverage cooler project adding temperature probe, 248 324 IndexArduino software, 250 attaching the cooling unit, 250 attaching the power socket, 250 design, 247 hardware, 246 parts list, 246 cooling (see heating and cooling) counterclockwise, motor turning, 134 sequence of coil activations to rotate stepper motor, 178 current, 59 maximum current for transistors, 63 Raspberry Pi GPIO pins, 62 transistors and, 65 current limiting resistors for LEDs, 77 D DallasTemperature library (Arduino), 224 Darlington transistors, 66 data pins (relay modules), 105 DC (direct current), 256 DC motors, 53 (see also motors) DC power socket (Arduino Uno), 11 delay() function, 16 experimenting with, in controlling a motor, 57 experimenting with, in controlling LED, 49 derivative control (PID), 232 digital I/O pins (Arduino Uno), 10 digital input and output digital inputs for Raspberry Pi and Arduino, 73 digital inputs in Arduino, 16 digital inputs in Raspberry Pi, 39 digital outputs for Raspberry Pi and Arduino, 73 digital outputs in Arduino, 16 digital outputs in Raspberry Pi, 38 digital outputs, connecting an LED to, 76 digitalRead() function, 17 digitalWrite() function, 16, 22 diodes, 71, 71 (see also LEDs) positioning on a breadboard, 54 direct current (see DC) displays, 267-282 experiment, controlling RGB LED strip display, 268-275 Arduino connections, 269 Arduino software, 270 parts lists, 269 Raspberry Pi connections, 271 Raspberry Pi software, 273 experiment, using I2C OLED display module with Raspberry Pi, 276-279 connections, 277 experimentation, 279 parts list, 276 software, 277 I2C OLED displays, 275 project, adding display to beverage cooler project, 279-282 connections, 280 parts list, 280 software, 281 distance, in torque calculations, 109 drain (MOSFETs), 68 DS18B20 temperature sensor, 220, 222 in PID thermostatic control experiment, 234 in thermostatic beverage cooler project, 246 using with Raspberry Pi in PID thermostat, 241 duty cycle, 85 entering value into Arduino Serial Monitor, 100 setting in Python program to control motor speed, 102 dweepy library, 307, 309 dweet.io web service, 307, 309 E electronics, basic, 59-74 common components, 63 capacitors, 72 diodes, 71 integrated circuits (ICs), 72 LEDs, 71 Index 325resistors, 63 transistors, 64-71 connections with Raspberry Pi and Arduino, 73 analog inputs, 73 digital inputs, 73 digital outputs, 73 current, voltage, and resistance, 59-62 power, 62 serial communication, 74 emitter (transistors), 64 energy needed to boil water, 210 power versus, 210 error (in output power calculaton), 230 ESP8266 module, 304 Ethernet connections (Raspberry Pi), 25 F fans, using with Peltier elements, 213 float type (in C), 18 for loops (in C), 21 forward voltage (Vf), 76 for different colors of LED, 77 FQP30N06L transistors, 71 frequencies (audio), 284 experimenting with, in Arduino, 286 functions, 15 in Arduino C, 22 writing your own, 22 variables in, 23 G gain (kp), 230 gain (or hFE), 65 gate (MOSFETs), 68 gearmotors, 110 gears, 110 getting started (quickstart), 41-58 connecting a breadboard to Raspberry Pi, 44 downloading the software, 45 exercise, controlling a motor, 53-58 Arduino connections to the breadboard, 56 Arduino experimentation, 57 breadboard layout, 54 experimenting with the breadboard, 55 parts list, 53 Raspberry Pi connections, 57 Raspberry Pi experimentation, 58 exercise, controlling an LED, 46-53 Arduino connections, 47 Arduino experimentation, 49 Arduino software, 48 breadboard layout, 46 comparing C and Python code, 52 parts list, 46 Raspberry Pi connections, 49 Raspberry Pi experimentation, 52 Raspberry Pi software, 51 solderless breadboard, 41 connecting a breadboard to Arduino, 43 inner workings of the breadboard, 43 GFX library, 281 git clone command, 34 git pull command, 35 Git, using to manage code, 34 GitHub repository for example code, 14 global variables, 23 GND (ground) connection, 55 GND (ground) pins (relay modules), 105 GPIO pins (Raspberry Pi), 2, 26 connecting a breadboard to, 44 current, 62 GPIO header, 37 identifying, 45 naming conventions for pins, 37, 51 RPi.GPIO library for control of, 37 GPIO sockets (Arduino), connecting to a breadboard, 43 GPIO.cleanup() function, 52 GPIO.input() function, 39 GPIO.output() function, 39 GPIO.setmode() function, 51 ground, 61 symbol for, in schematic diagrams, 69 326 IndexH H-bridge modules, 147 in can crusher project, 149 wiring, 150 H-bridges, 126, 230 H-bridge ICs, 128 L293D, 178 L298N, 143 pinout of L293D H-bridge IC, 130 TB6612FNG, 147 using L293D IC to control speed and direction of a motor, 130-143 switch combinations, 127 half-sized breadboards, 41 hardware, 316 HDMI video connector (Raspberry Pi), 26 header pins (Raspberry Pi), 26 heat generated by current passing through a resistor, 62 heat loss and equilibrium, 211 specific heat capacity (SHC) of materials, 210 heat sinks, using with Peltier elements, 212 heating and cooling, 203-218 Arduino random balloon popper project, 205-209 hardware, 206 parts list, 206 software, 208 timing the balloon pop, 209 beverage cooler project, 215-218 construction, 216 parts list, 215 from power to temperature increase, 210 boiling water, 210 heating elements, 209 Peltier elements, 211 how they work, 211 practical considerations with, 212 power and energy, 210 resistive heaters, 203 resistor heating experiment, 203-205 construction, 204 experimenting, 204 parts list, 203 "Hello, World" program in Bottle, 300 "Hello, World" program in Python, 35 hertz (Hz), 256 hFE (gain), 65 hobby servos, 154 house plant waterer project, 114-120 Arduino software, 118 construction, 116 breadboard, 116 final assembly, 118 fixing tubing onto the pump, 117 soldering leads to a motor, 116 design, 114 parts list, 115 running the project, 120 HTML Bottle templates for, 302 generating with Bottle, 300 hysteresis, 228 Hz (hertz), 256 I I2C, 74 interface for Raspberry Pi puppet, 169 setting up Raspberry Pi to use, 171 I2C OLED displays (see OLED displays) ICs (see integrated circuits) IDEs (integrated development environments) for Arduino, 4 installing the Arduino IDE on your computer, 11 if statement in C, 17 in Python, 36 if/else statement in C, 20 in Python, 36 IFTTT (If This Then That) cloud service, 299, 309 adding the web request action, 310 creating a new recipe, 309 defining the trigger, 310 finishing the recipe, 311 testing by tweeting #dancepepe hashtag, 311 Index 327impedance, 283 indentation in Python code, 35 inductance, 283 infrared (IR) LEDs, 76 input and output (see analog input and output; digital input and output) input/output (I/O) GPIO pins on Raspberry Pi, 26 int type (in C), 15 integral control (PID control), 231 integrated circuits (ICs), 72 DS18B20 digital thermometer IC, 221 H-bridge ICs, 128 Intel Edison, 6 IoT (Internet of Things), 299-312 Arduino and networks, 303 platforms for use with, 6 project, puppet Twitter notifier, 305-311 IFTTT monitoring, setting up, 309-311 putting Pepe on the Internet, 306 project, Raspberry Pi web switch, 301-303 hardware, 301 software, 302 Raspberry Pi and Bottle, 300 IP address, finding for Raspberry Pi, 31 J joules, 210 K kd value, 232 keyboard and mouse (Raspberry Pi), 27 ki constant, 232 kp (gain), 230 ku value, 232 L L293D H-bridge IC, 128, 178 pinout, 130 schematic diagram, 128 using to control a bipolar stepper motor, Aruduino connections, 181 using to control direction and speed of a motor, 130 schematic diagram, 132 L298N H-bridge IC, 143 measuring the motor's current, 145 pinout, 144 LED strips, 267 addressable LED power consumption, 270 controlling RGB LED strip display, 268-275 Arduino connections, 269 Arduino software, 270 parts list, 269 Raspberry Pi connections, 271 Raspberry Pi software, 273 using level converter to raise voltage of control signal, 272 LEDs, 71, 75-93 connection to Arduino Uno, 10 current limiting, 76 exercise, controlling an LED, 46-53 Arduino connections to the breadboard, 47 breadboard layout, 46 comparing C and Python code, 52 parts list, 46 Raspberry Pi connections, 49 Raspberry Pi experimentation, 52 Raspberry Pi software, 51 experiment, mixing colors, 86-93 Arduino connections, 88 Arduino experimentation, 90 Arduino sketch for, 89 hardware, 86 parts list, 88 Raspberry Pi connections, 90 Raspberry Pi experimentation, 93 Raspberry Pi software, 91 in optoisolators, 258 OLED displays, 275 adding display to beverage cooler, 279-282 using I2C display module with Raspberry Pi, 276-279 pulse with modulation (PWM) and, 84 328 Indexregular, 76 connecting to digital output, 76 RGB (red, green, and blue), 85 traffic signal project, 78-84 Arduino connections, 80 Arduino sketch for, 81 design, 80 parts list, 79 Raspberry Pi connections, 82 Raspberry Pi software, 83 linear actuators, 120, 149 in beverage can crusher project, 150 Linux Arduino IDE on, 11 downloading example code from GitHub, 14 operating system for Raspberry Pi, 28 Raspberry Pi command line, 32 serial port for Arduino board, 13 SSH on, 32 local variables, 23 Log area (Arduino IDE), 11 logic-level MOSFETs, 70 loop() function, 15 defining digital inputs, 17 for controlling an LED, 49 loops in C, 21 in Python, 36 loudspeakers, 283 LXTerminal (Raspberry Pi), 29 executing commands over SSH, 32 hostname -I command, 31 M mA (milliamps), 60 Mac computers Arduino IDE on, 11 downloading example code from GitHub, 14 serial port for Arduino board, 13 SSH on, 32 map() function, 253 metal-oxide-semiconductor field-effect transistors (see MOSFETs) micro USB connector (Raspberry Pi), 26 microcontroller IC, ATMega328, 10 microSD card (Raspberry Pi), 2, 26 preparing with NOOBS, 28 milliamps (mA), 60 MOSFETs, 67 FQP30N06L high power MOSFET, 248 in RGB LED strip display experiment, 269 PNP and P-channel transistors, 70 motors, 95-123 choosing, 108 gearmotors, 110 gears, 110 RPM, 109 torque, 108 controlling DC motors with a relay, 102-106 relay modules, 105 switching a relay with Arduino or Raspberry Pi, 103 controlling direction of, 125-152 H-bridge ICs, 128 H-bridges, 126 controlling speed with PWM, 96 exercise, controlling a motor, 53-58 Arduino experimentation, 57 breadboard layout, 54 Darlington transistor, 66 experimenting with the breadboard, 55 parts list, 53 schematic diagram, 59 experiment, controlling a DC motor with a relay module, 106-108 Arduino software, 107 parts list, 106 Raspberry Pi software, 108 wiring, 106 experiment, controlling direction and speed of a motor, 130-143 Arduino connections to H-bridge, 136 Arduino experimentation, 139 Arduino software, 137 avoiding damage to the motor, 143 breadboard layout, 133 design, 132 experimenting with direction, 135 parts list, 131 Raspberry Pi connections, 140 Index 329Raspberry Pi experimentation, 142 Raspberry Pi software, 141 experiment, controlling speed of a DC motor, 96-102 Arduino connections, 97 Arduino experimentation, 100 Arduino software, 98 hardware, 96 Raspberry Pi connections, 100 Raspberry Pi experimentation, 102 Raspberry Pi software, 101 how DC motors work, 96 linear actuators, 120 pumps, 110 house plant waterer project, 114-120 peristaltic pumps, 111 velocity pumps, 112 range of DC motors, 95 solenoids, 122 voltage spikes caused by, handling with diodes, 71 movement detection, PIR sensors, 295, 296 MPSA14 transistors, 71 N N (newtons), 109 N-channel transistors, 70 nano editor, 33 negative positive negative (NPN), or N-channel transistors, 70 NeoPixels, 267 Adafruit NeoPixel library, 270 connecting to Raspberry Pi, 271 logic level and, 269 on Raspberry Pi, Adafruit tutorial on, 273 network connections, Raspberry Pi, 25 networks Arduino and, 303 making Arduino or Raspberry Pi network capable, 299 newtons (N), 109 NOOBS, using to prepare microSD card for Raspberry Pi, 28 normally closed (NC) terminals, 103, 107 normally open (NO) terminals, 103, 107 numbers, reading from Arduino Serial Monitor, 99 O Ohm's Law, 61, 77 ohms, 61 OLED displays adding display to beverage cooler project, 279-282 screen coordinates, 278 using I2C display module with Raspberry Pi, 276-279 connections, 277 experimentation, 279 parts list, 276 software, 277 OLED library, 277 omega (Ω), 61 OneWire library (Arduino), 224 OpenOffice, 238 operating system, choosing for Raspberry Pi, 28 optoisolators, 257 relay modules with, 262 zero-crossing optoisolators and TRIACs, 258 organic LEDs (see OLED displays) output power calculating for PID control, 232 calculating in P (proportional) control, 230 calculating in PI control, 231 P P-channel transistors, 70 parseInt() function, 99 parts, 313-317 hardware, 316 miscellaneous, 317 resistors and capacitors, 314 semiconductors, 315 suppliers, 313 parts lists for balloon popper project, 206 for beverage cooler project, 215 330 Indexfor can crusher project, 149 for controlling a bipolar stepper motor, 179 for controlling a DC motor with a relay module, 106 for controlling a motor, 53 for controlling an LED, 46 for controlling direction and speed of a motor, 131 for controlling RGB LED strip display, 269 for controlling servomotor position, 156 for house plant waterer project, 115 for I2C OLED display, 276 for LED traffic signal project, 79 for Pepe, dancing Raspberry Pi puppet, 164 for playing sound files on Arduino, 287 for resistor heating experiment, 203 for RGB LED experiment, 88 for talking puppet project, 294 for thermostatic beverage cooler project, 246 for thermostatic on/off control experiment, 221 for timer switch project, 263 for unamplified speaker with Arduino, 284 passive infrared sensors (see PIR sensors) PCBs (printed circuit boards), 72 PCM (pulse code modulation), 287, 288 PCM library, 289 Peltier effect, 211 Peltier elements, 211, 230 beverage cooler project, 215-218 cooling unit for thermostatic beverage cooler, 250 how they work, 211 practical considerations, 212 Pepe, dancing Raspberry Pi puppet, 162-174 adding your own movements for, 173 attaching the puppet to servos, 171 construction, 165 adapting the puppet, 168 extending servo arms, 165 gluing the servos, 168 making a chassis, 166 wiring everything up, 169 design of project, 164 parts list, 164 running test program, 170 Twitter notifier, 305-311 putting Pepe on the Internet, 306 voice for Pepe, 293-298 breadboard layout, 295, 295 parts list, 294 software, 296 peristaltic pumps, 111 house plant waterer project, 114-120 photo-TRIACs, 258 Photon, 6, 303 photoresistors, 119 phototransistors, 258 PID control (see proportional-integral-derivative control) PID library (Arduino), 234 PIL (Python Image Library), 279 pinMode() function, 17 for controlling an LED, 48 pinouts, 317 L293D H-bridge IC, 130 L298N H-bridge IC, 144 transistor, 69 pins on relay modules, 105 PIR (passive infrared) sensors, 294 movement detection, 296 pitch, 284 PNP (positive negative positive) transistors, 70 pointers (in C), 236 polarized capacitors, 72 pot (see potentiometers) potentiometers, 247 power, 62 consumed by addressable LEDs, 270 energy versus, 210 for a heating element, 209 from power to temperature increase, 210 of heating elements, 209 power rating for resistors, 64 power connectors (Arduino Uno), 11 power law (P = I V), 204, 209 power LED (Arduino Uno), 10 power socket, attaching (thermostatic cooler), 250 PowerSwitch Tail, 263 in Raspberry Pi timer switch, 263-266 printed circuit boards (PCBs), 72 Index 331printers, stepper motors in, 176 proportional-integral-derivative (PID) control, 219, 229 derivative control, 232 integral control, 231 PID control for beverage cooler, 250 PID thermostatic control experiment, 233-245 Arduino experimentation, 236 Arduino software, 234 hardware, 234 Raspberry Pi connections, 240 Raspberry Pi experimentation, 245 Raspberry Pi software, 241 proportional control, 230 tuning a PID controller, 232 pu value, 233 pull-up resistors in Raspberry Pi digital inputs, 39 using with digital input in Arduino, 17 pulse code modulation (PCM), 287, 288 installing PCM library in Arduino, 289 pulse width modulation (PWM) controlling servomotors, 154, 155 hardware modules for, 162 in Arduino PID thermostatic control experiment, 236, 237 Raspberry Pi controlling servomotor position, 161 pulse-width modulation (PWM), 19, 74 and LEDs, 84 controlling motor speed with, 96 in Arduino sketch for mixing colors in RGB LEDs, 89 in Python program for RGB LED color mixing, 92 setting in Python program to control motor speed, 102 pumps, 110 peristaltic, 111 velocity, 112 volumetric flow rate, 112 puppet project (see Pepe, dancing Raspberry Pi puppet) PuTTY, downloading and installing on Windows, 31 pygame library, 293 Python Bottle web server framework, 300 dancing puppet program, 172 dweepy library, 307 map() function, writing, 253 playing sound files, 293 program for controlling a DC motor with a relay module, 108 program for PID thermostat, 242 program for puppet on the Web, 307 program for puppet voice, 296 program for timer switch, 265 program for traffic signal project, 83 program to control a bipolar stepper motor, 188 program to control a DC motor's speed, 101 program to control a motor's direction and speed, 141 program to control an LED, 51 comparing to C code, 52 program to control servomotor position, 160 program to set servos' position, 171 programming primer for Raspberry Pi, 35-39 "Hello, World" program, 35 if and while statements, 36 RPi.GPIO library, 37 tabs and indents in code, 35 programs for I2C OLED display, 277 programs for NeoPixel display, 273 puppet project test program, 170 Python 2 versus Python 3, 35 Raspberry Pi and, 2 test.py program, running on Raspberry Pi, 33 R random balloon popper (see balloon popper project) random numbers in Arduino C, 208 Raspberry Leaf, 45 Raspberry Pi, 1, 25-39 alternatives to, 5 analog outputs, 74 Bottle, 300 choosing, Arduino versus, 4 332 Indexcode from this book, 34 connecting a breadboard to, 44 controlling a bipolar stepper motor, 187 experimenting with Raspberry Pi, 190 Python program for, 188 controlling a DC motor with a relay module, software for, 108 controlling a motor with breadboard connections, 57 Raspberry Pi experimentation, 58 controlling an LED with breadboard connections, 49 Python program for, 51 Raspberry Pi experimentation, 52 controlling DC motor's speed (experiment) Python program for, 101 Raspberry Pi connections, 100 Raspberry Pi experimentation, 102 controlling motor's direction and speed, 130-135 connecting to H-bridge, 140 Python program for, 141 Raspberry Pi experimentation, 142 controlling position of a servomotor connecting Raspberry Pi, 160 experimenting with Raspberry Pi, 162 Python program for, 160 controlling RGB LED strip display parts list, 269 Raspberry Pi connections, 271 Raspberry Pi software, 273 differences from other computers running Linux, 2 digital inputs, 73 digital outputs, 73 GPIO pin current, 62 LED traffic signal project Raspberry Pi connections, 82 Raspberry Pi software, 83 Linux command line, 32 making network and Internet capable, 299 overview, 25 Pepe, the dancing puppet project, 162-174 running test program, 170 schematic diagram, 164 setting up Pi to use I2C, 171 software for, 172 PID thermostatic control experiment connecting Raspberry Pi, 240 experimenting with Raspberry Pi, 245 Raspberry Pi software, 241 playing sound files on, 293 programming guide, 35-39 analog outputs, 39 digital inputs, 39 digital outputs, 38 GPIO header, 37 "Hello, World" program, 35 if and while statements, 36 RPi.GPIO library, 37 tabs and indents in Python code, 35 variables, 36 pulse-width modulation (PWM) on output pins, 85 RGB LED experiment, 90 Python program for, 91 Raspberry Pi experimentation, 93 serial communication, 74 setting up, 27 example of typical setup, 27 preparing microSD card with NOOBS, 28 SSH, 29 switching relays with, 103 timer switch project, 263-266 using I2C display module with, 276-279 connections, 277 experimentation, 279 software, 277 web switch, 301-303 Raspberry Pi 2 model B, overview of, 25 specs, 2 Raspbian OS, 28 updating, 51 raspi-config tool, 30 setting up Pi to use I2C, 171 RasPiRobot V3 board, 148 recording a sound clip, 287 reference (set temperature), 220 relay modules, 105, 260 active-low or active-high, checking, 261 controlling a DC motor with, 106-108 Index 333Arduino software, 107 parts list, 106 Raspberry Pi software, 108 wiring, 106 using safely, 260 relays, 257 controlling DC motors with, 102 switching a relay with Arduino or Raspberry Pi, 103 electromechanical, 103 solid-state relays (SSRs), 262 Reset button (Arduino Uno), 9 resistance, 61 for MOSFETs, 70 resistive heaters, 203 resistors bipolar transistors and, 65 color codes, 63 reading, 64 for controlling an LED, 46, 47 for LED traffic signal project, 80 for RGB LED experiment, 88 heat generated by, 203 heating resistor used with DS18B20 temperature sensor, 223 power produced by, 62 power rating, 64 random balloon popper poject, 205-209 reference, 314 resistor heating experiment, 203-205 construction, 204 experimenting, 204 parts list, 203 series resistor online calculator, 77 use with LEDs, 77 current limiting resistors, 77 use with MOSFET transistors, 69 using pull-up resistor with digital input in Arduino, 17 RGB (red, green, and blue) LEDs, 85, 267 experiment, mixing colors, 86-93 Arduino connections, 88 Arduino experimentation, 90 Arduino software, 89 hardware, 86 parts list, 88 Raspberry Pi connections, 90 Raspberry Pi experimentation, 93 Raspberry Pi software, 91 RGB LED strips, 267 controlling display of, 268-275 RMS voltage, 256 rotors, 96 RPi.GPIO library, 37, 51 PWM feature, 160 RPM (revolutions per minute), 109 S schematic diagrams common cathode RGB LED, 85 for an L293D H-bridge, 132 for controlling a bipolar stepper motor, 180 for controlling a motor, 59 for MOSFET transistors, 67 for puppet project, 164 for thermostatic beverage cooler project, 248 for thermostatic on/off control experiment, 222 symbol for LEDs, 71 symbols for capacitors, 72 semiconductors, 315 in Peltier elements, 212 sensors connecting to analog inputs in Arduino, 19 monitoring actuators, 219 sensors and actuators in control systems (see control loops) serial communication, 74 Serial Monitor (Arduino IDE), 12 controlling bipolar stepper motor, 186 controlling servomotor's position with, 159 putting data into a spreadsheet, 238 using in program to control DC motor's speed, 98 using to control motor speed, 100 using to control motor's direction and speed, 139 using to mix colors in RGB LED experiment, 90 using to test PID control, 236 334 Indexserial peripheral interface (SPI), 74 serial port for Arduino sketch upload, setting, 13 Serial.available() function, 99 Serial.begin() function, 99 servo library (Arduino), 159 servomotors, 153-174 9g and standard, 153 connections, 157 controlling, 154 experiment, controlling position of a servomotor, 155-162 Arduino experimentation, 159 Arduino software, 158 Arduino, connecting to a servomotor, 157 hardware, 156 parts list, 156 Raspberry Pi connections, 160 Raspberry Pi experimentation, 162 Raspberry Pi software, 160 how they work, 154 project, Pepe dancing Raspberry Pi puppet, 162-173 adapting the puppet, 168 attaching the puppet to servos, 171 construction, 165 design, 164 extending servo arms, 165 gluing the servos, 168 making a chassis, 166 parts list, 164 software, 172 wiring everything up, 169 set temperature, 220 setup() function, 15 defining digital input pin, 17 digital output in Blink example, 16 for controlling an LED, 48 for loops in, 21 SHC (specific heat capacity), 210 shields for Arduino, 4 H-bridge shields for Arduino and Raspberry Pi, 148 sine waves, 286 Single Pole Change Over (SPCO) relays, 103 sketches (Arduino), 13 downloading from Github, 14 for balloon popper project, 208 for can crusher, 151 for controlling a bipolar stepper motor, 183 for controlling a DC motor with a relay module, 107 for controlling an LED, 48 for controlling DC motor's speed, 98 for controlling motor's direction and speed, 137 for controlling RGB LED strip display, 270 for controlling servomotor position, 158 for house plant waterer project, 118 for LED traffic signal project, 81 for PID thermostat experiment, 234 for playing a sound file, 289 for RGB LED experiment, 89 for speaker with Arduino, 285 for thermostatic beverage cooler project, 251 for thermostatic on/off control experiment, 225 solderless breadboards, 41 inner workings of, 43 solenoids, 122 solid-state relays (SSRs), 257, 262 sound, 283-298 amplifiers, 286 connecting Arduino to an amplifier, 290 experiment, playing sound files on Arduino, 287-290 Arduino code, 289 Arduino experimentation, 290 parts list, 287 recording a sound clip, 287 experiment, unamplified speaker and Arduino, 283-286 Arduino experimentation, 286 Arduino software, 285 parts list, 284 playing sound files on Raspberry Pi, 293 project, voice for Pepe the puppet, 293-298 parts list, 294 software, 296 sound waves, 284 source (MOSFETs), 68 speakers Index 335amplifiers for, 286 unamplified speaker and Arduino, 283-286 specific heat capacity (SHC), 210 speed of a DC motor, controlling (see motors) SPI (see serial peripheral interface) spreadsheet, importing Serial Monitor data into, 238 square waves, 286 SSD1306 library, 281 SSH connection, setting up for Raspberry Pi, 29 on Mac or Linux computers, 32 on Windows computers, 31 SSRs (see solid-state relays) standard servomotors, 154 stationary magnets (stator), 96 Status area (Arduino IDE), 12 Stepper library (Arduino), 185 stepper motors, 175-202 bipolar, 176 examples of, 176 experiment, controlling a bipolar stepper motor, 178-190 Arduino connections, 181 Arduino experimentation, 186 Arduino software, 183 Arduino, using, 181 parts list, 179 Raspberry Pi connections, 187 Raspberry Pi experimentation, 190 Raspberry Pi software, 188 Raspberry Pi, using, 187 schematic diagram, 180 identifying leads, 179 unipolar, 190 strings in Python, 36 sudo command, 33 using with Python color mixing program, 93 using with Python program to control a motor, 58 using with Python program to control an LED, 52 sugar cube relays, 103 superuser (Linux), 33 suppliers for parts, 313 switches connected to digital input in Arduino, 17 H-bridge using, 126 T tabs in Python code, 36 taffic signal project with LEDs, 78-84 TB6612FNG H-bridge IC, 147 temperature from power to temperature increase, 210 set and actual temperature, 220 temperature probe, 248 text, numbers and, 99 thermoelectric effect, 211 thermostats, 219 hysteresis in, 228 on/off thermostatic control experiment, 220-228 breadboard layout, 223 design, 222 parts list, 221 software, 224 PID thermostatic control experiment, 233-245 thermostatic beverage cooler project, 246-254 timer switch project, 263-266 parts list, 263 Raspberry Pi software, 265 using, 266 wiring diagram, 264 TIP120 transistors, 71 Tkinter framework (Python), 91 torque, 108 traffic signal project with LEDs Arduino connections, 80 Arduino software, 81 design, 80 parts list, 79 Raspberry Pi connections, 82 Raspberry Pi software for, 83 transistors, 53 bipolar, 65 Darlington, 66 FQP30N06L MOSFET, 248 in on/off thermostatic control experiment, 224 336 IndexMOSFET, 67 PNP and P-channel transistors, 70 overview, 64 package types, 65 positioning on a breadboard, 54 power and heat, 62 selection guide, 70 transistor-based optoisolator, 257 TRIACs, 258 using to switch a relay, 103 varied pinouts, 69 TRIACs, 258 try/finally statement (Python), 52 TTL serial, 74 tuning the system, 231 tuning a PID controller, 232 Twitter notifier for Pepe the Puppet (project), 305-311 monitoring Twitter for hashtag mentions with IFTTT, 309-311 types in Python, 36 specifying for function parameters in C, 23 U ultraviolet (UV) LEDs, 76 unipolar stepper motors, 190 unpolarized capacitors, 72 uploading sketches to Arduino board, 11 USB ports (Raspberry Pi), 25 USB socket (Arduino Uno), 9 V V (volts), 61 variables in C, 15 global and local variables, 23 in Python, 36 VCC or 5 pins (relay modules), 105 velocity pumps, 111, 112 Verify button (Arduino IDE), 11 Vf (forward voltage), 76 for different colors of LED, 77 video connector, Raspberry Pi, 26 void keyword (in C), 23 voltage about, 60 AC (alternating current), 256 analog outputs in Arduino, 19 converting analogRead() return to, 18 for bipolar transistors, 65 gate threshold voltage for MOSFETs, 69 using level converter to raise 3V control signal to 5V, 272 working voltage for a heating element, 209 voltage divider, 290 volts (V), 61 volumetric flow rate, 112 W W (see watts) water, boiling, 210 watts (W), 62 joules versus, 210 WAV files exporting from Audacity, 288 playing on Arduino, 287 playing on Raspberry Pi, 293 web browsers, controlling Pepe the puppet from, 307 web servers Arduino or Raspberry Pi acting as, 299 Raspberry Pi and Bottle, 300 web switch (Raspberry Pi), 301-303 while loops in C, 21, 21 in Python, 36 controlling an LED, 52 True condition, 52 WiFi Arduino and, 303 ESP8266 module, 304 Photon board, 304 WiFi adapter for Raspberry Pi, 25 Windows systems Arduino IDE on, 11 dowloading example code from Github, 14 Index 337serial port for Arduino, 13 SSH on, 31 wireless networks, configuring Raspberry Pi to join, 28 wiring diagrams for can crusher, 150 for controlling a DC motor with a relay module, 106 for Raspberry Pi timer switch, 264 WS2812 addressable LEDs, 267 Z zero-crossing optoisolators, 258 Ziegler-Nichols method (PID tuning), 232, 239 ZIP files, example code downloads, 14
كلمة سر فك الضغط : books-world.net The Unzip Password : books-world.net أتمنى أن تستفيدوا من محتوى الموضوع وأن ينال إعجابكم رابط من موقع عالم الكتب لتنزيل كتاب Make: Action - Movement, Light, and Sound with Arduino and Raspberry Pi رابط مباشر لتنزيل كتاب Make: Action - Movement, Light, and Sound with Arduino and Raspberry Pi
|
|