Arduino Projects Book - WordPress

3y ago
140 Views
18 Downloads
7.23 MB
175 Pages
Last View : 17d ago
Last Download : 2m ago
Upload by : Rosa Marty
Transcription

ARDUINOPROJECTSBOOK

THE ARDUINO PROJECTS BOOKEDITORSProjects and text by Scott Fitzgerald and Michael ShilohAdditional text review by Tom IgoeDESIGN AND ART DIRECTIONTODOGiorgio Olivero, Mario Ciardulli, Vanessa Poli, Michelle Nebiolotodo.to.itDIGITAL FABRICATION AND PROJECT MANAGEMENTOfficine Arduino TorinoKatia De Coi, Enrico BassiADVISORS AND SUPPORTERSMassimo Banzi, Gianluca Martino, Smart ProjectsPROJECT TESTERS AND PROOFREADERSMichael Shiloh, Michelle Nebiolo, Katia De Coi, Alessandro Buat,Federico Vanzati, David MellisTHANKSBig thanks to the entire Arduino user community for their continued contributions, support, and feedback.Special thanks to the Fritzing team: some of the electronic components illustrations used in the book are taken or modified fromthe open-source Fritzing project (www.fritzing.org).Heartfelt thanks to Paul Badger for the CapacitiveSensor libraryused in Project 13.The text of the Arduino Projects Book is licensed under a CreativeCommons Attribution-NonCommercial-ShareAlike 3.0 License 2012 byArduino LLC. This means that you can copy, reuse, adapt and buildupon the text of this book non-commercially while attributing theoriginal work (but not in any way that suggests that we endorseyou or your use of the work) and only if the results are transmittedunder the same Creative Commons license.Full license terms: creativecommons.org/licenses/by-nc-sa/3.0/ 2012 Arduino LLC. The Arduino name and logo are trademarks ofArduino, registered in the US and in the rest of the world. Otherproduct and company names mentioned herein are trademarks of theirrespective companies.The information in this book is distributed on an “As Is” basiswithout any further warranties. While every precaution has beentaken in the design of this book, neither the authors nor ArduinoLLC shall have any liability to any person or entity with respectto any loss or damage caused or declared to be caused directly orindirectly by the instructions contained in this book or by thesoftware and hardware described in it.This book cannot be sold separately from The Arduino Starter Kit.Designed, printed and bound in Torino, ItalySeptember 2012

INDEX400INTRODUCTION2001Get to Know Your Tools3202Spaceship Interface4203Love-o-Meter5204Color Mixing Lamp6205Mood Cue7006Light Theremin7807Keyboard Instrument8608Digital Hourglass9409Motorized Pinwheel10210Zoetrope11411Crystal Ball12412Knock Lock13613Touchy-feely Lamp14414Tweak the Arduino Logo15615Hacking Buttons162A/Z GLOSSARY

00Everyone, every day, uses technology. Most of us leave theprogramming to engineers because we think coding andelectronics are complicated and difficult; actually, they can befun and exciting activities. Thanks to Arduino, designers, artists,hobbyists and students of all ages are learning to create thingsthat light up, move, and respond to people, animals, plants, andthe rest of the world.Over the years Arduino has been used as the “brain” in thousandsof projects, one more creative than the last. A worldwidecommunity of makers has gathered around this open-sourceplatform, moving from personal computing to personalfabrication, and contributing to a new world of participation,cooperation and sharing.Arduino is open and simple. It’s founded on lessons we’ve learnedteaching our own classes: if you start with the assumption thatlearning to make digital technologies is simple and accessible,you can make it so. Suddenly electronics and code becomecreative tools that anyone can use – like brushes and paint.This book walks you through the basics in a hands-on way, withcreative projects you build by learning. Once you’ve masteredthe basics, you’ll have a palette of software and circuits that youcan use to create something beautiful, and make someone smilewith what you invent.BECOME EXTRAORDINARY

WELCOME TOARDUINO!ARDUINO MAKES IT AS EASY AS POSSIBLETO PROGRAM TINY COMPUTERS CALLEDMICROCONTROLLERS, WHICH ARE WHAT MAKEOBJECTS INTERACTIVEYou are surrounded by dozens of them every day: they are embedded in timers,thermostats, toys, remote controls, microwave ovens, even some toothbrushes.They just do one specific task, and if you hardly notice them – which is often thecase – it’s because they are doing it well. They have been programmed to senseand control activity using sensors and actuators.Sensors listen to the physical world. They convert energy that you give off whenyou press buttons, or wave your arms, or shout, into electrical signals. Buttonsand knobs are sensors that you touch with your fingers, but there are many otherkinds of sensors.Actuators take action in the physical world. They convert electrical energy backinto physical energy, like light and heat and movement.Microcontrollers listen to sensors and talk to actuators. They decide what todo based on a program that you write.Microcontrollers and the electronics you attach to them are just the skeleton ofyour projects, though. You’ll need to bring skills you probably already have to putsome flesh on the bones.For example, in one of the projects we suggest, you’ll make an arrow and attach itto a motor, and put them both in a box with a knob, so you can make a meter totell people whether you’re busy or not. In another, you’ll put some lights and a tiltswitch on a cardboard frame to make an hourglass.Arduino can make your projects responsive, but only you can make thembeautiful. We’ll provide some suggestions along the way as to how you mightdo that.Arduino was designed to help you get things done. To make that happen, we keptthe background material on programming and electronics to a minimum. If youdecide you want to know more about these aspects, there are lots of good guidesavailable. We’ll provide a couple of references, and you can find more online at:arduino.cc/starterkit

6IntroductionWelcome to Arduino! - - -PARTS INYOUR KIT - Breadboard - A board on which you can buildelectronic circuits. It’s like a patch panel, withrows of holes that allow you to connect wiresand components together. Versions that require soldering are available, as well as the solder-less type used here.Arduino Uno - The microcontroller development board that will be at the heart of yourprojects. It’s a simple computer, but one thathas no way for you to interact with it yet. YouCapacitors - These components store and release electrical energy in a circuit. When thecircuit’s voltage is higher than what is stored inthe capacitor, it allows current to flow in, giving the capacitor a charge. When the circuit’swill be building the circuits and interfaces forvoltage is lower, the stored charge is released.Often placed across power and ground close tointeraction, and telling the microcontroller howto interface with other components.a sensor or motor to help smooth fluctuationsin voltage.Battery Snap - Used to connect a 9V battery topower leads that can be easily plugged into aDC motor - Converts electrical energy into mechanical energy when electricity is applied toits leads. Coils of wire inside the motor becomebreadboard or your Arduino.magnetized when current flows through them.

7These magnetic fields attract and repel magnets, causing the shaft to spin. If the directionof the electricity is reversed, the motor will spinin the opposite direction.- Diode - Ensures electricity only flows in one direction. Useful when you have a motor or otherhigh current/voltage load in your circuit. Diodes are polarized, meaning that the directionthat they’re placed in a circuit matters. Placedone way, they allow current to pass through.Placed the other way, they block it. The anodeside generally connects to the point of higherenergy in your circuit. The cathode typicallyconnects to the point of lower energy, or toground. The cathode is usually marked with aband on one side of the component’s body.Jumper wires - Use these to connect components to each other on the breadboard, and tothe Arduino.- Light Emitting Diodes (LEDs) - A type of diodethat illuminates when electricity passes throughit. Like all diodes, electricity only flows in onedirection through these components. You’reprobably familiar with these as indicators on avariety of electronic devices. The anode, whichtypically connects to power, is usually the longer leg, and the cathode is the shorter leg.Gels (red, green, blue) - These filter out different wavelengths of light. When used in conjunction with photoresistors, they cause thesensor to only react to the amount of light inthe filtered color.H-bridge - A circuit that allows you to controlthe polarity of the voltage applied to a load,usually a motor. The H-bridge in the kit is an in-Liquid Crystal Display (LCD) - A type of alphanumeric or graphic display based on liquid crystals. LCDs are available in a many sizes, shapes,tegrated circuit, but it could also be constructed with a number of discrete components.and styles. Yours has 2 rows with 16 characterseach.

8IntroductionWelcome to Arduino!Male header pins - These pins fit into femalesockets, like those on a breadboard. They helpmake connecting things much easier.Potentiometer - A variable resistor with threepins. Two of the pins are connected to the endsof a fixed resistor. The middle pin, or wiper,moves across the resistor, dividing it into twohalves. When the external sides of the potenOptocoupler - This allows you to connect twocircuits that do not share a common powersupply. Internally there is a small LED that,when illuminated, causes a photoreceptor inside to close an internal switch. When you apply voltage to the pin, the LED lights and theinternal switch closes. The two outputs replacea switch in the second circuit.tiometer are connected to voltage and ground,the middle leg will give the difference in voltageas you turn the knob. Often referred to as a pot.Pushbuttons - Momentary switches that closea circuit when pressed. They snap into breadboards easily. These are good for detecting on/off signals.Piezo - An electrical component that can beused to detect vibrations and create noises.Photoresistor - (also called a photocell, or lightdependent resistor). A variable resistor thatchanges its resistance based on the amount oflight that falls on its face.Resistors - Resist the flow of electrical energyin a circuit, changing the voltage and currentas a result. Resistor values are measured inohms (represented by the Greek omega character: Ω). The colored stripes on the sides ofresistors indicate their value (see resistor colorcode table).

9ling high current/high voltage components likemotors. One pin connects to ground, anotherto the component being controlled, and thethird connects to the Arduino. When the component receives voltage on the pin connectedto an Arduino, it closes the circuit between theground and the other component.Servo motor - A type of geared motor thatcan only rotate 180 degrees. It is controlled bysending electrical pulses from your Arduino.These pulses tell the motor what position itshould move to.Temperature sensor - Changes its voltage output depending on the temperature of the component. The outside legs connect to power andground. The voltage on the center pin changesas it gets warmer or cooler.Tilt sensor - A type of switch that will open orclose depending on its orientation. Typicallythey are hollow cylinders with a metal ball inside that will make a connection across twoleads when tilted in the proper direction.Transistor - A three legged device that can operate as an electronic switch. Useful for control-USB Cable - This allows you to connect yourArduino Uno to your personal computer forprogramming. It also provides power to the Arduino for most of the projects in the kit.

UNCONNECTED WIRESTRANSISTORPUSHBUTTONTILT SWITCHMOSFETMOTORRESISTORPHOTO RESISTORPOTENTIOMETERLEDDIODEPIEZOPOLARIZED CAPACITORCAPACITORBATTERYIn this book we will show you circuits both with realisticillustrations and with schematic diagrams.Illustrations will give you an idea of what the breadboardGROUNDmight look like in one possible implementation of the project.Schematics, instead, use symbols to capture the essence ofcircuits: they present the components and the ways they areconnected in a clear, succinct, and unambiguous form, but notCONNECTED WIREStheir physical organization. Schematics and schematic symbolsare how we communicate about circuits. As you explore the worldof electronics you will discover that some books and websitesonly provide schematic diagrams, so learning to read circuits thisway is a valuable skill.Here are the symbols we will be using throughout the book.TABLE OF SYMBOLS

11THE BOARDPower connectorReset ButtonThis is how you power yourArduino when it's not pluggedinto a USB port for power. Canaccept voltages between 7-12V.Resets the ATmegamicrocontroller.USB portUsed for powering yourArduino Uno, uploading yourTX and RX LEDssketches to your Arduino, andfor communicating with yourArduino sketch (via Serial.println() etc.)These LEDs indicate communication between your Arduinoand your computer. Expectthem to flicker rapidly duringsketch upload as well as duringserial communication. Usefulfor debugging.Digital pinsUse these pins with digitalRead(), digitalWrite(), andanalogWrite(). analogWrite()works only on the pins with thePWM symbol.Pin 13 LEDThe only actuator built-it toyour Arduino Uno. Besidesbeing a handy target for yourfirst blink sketch, this LED isvery useful for debugging.GND and 5V pinsUse these pins to provide 5VATmega microcontrollerThe heart of your Arduino Uno.power and ground to yourcircuits.Analog inUse these pins withPower LEDIndicates that your ArudinoanalogRead().is receiving power. Useful fordebugging.

12IntroductionWelcome to Arduino!Your Starter Kit includes a precut, easy-to-assemble woodenbase that will make working onall your projects – whetherthey are from this book or not– even easier.To build it, take the wood sheetout of the box and follow theinstructions on the right.Be careful to use only theparts that are shown, but don’tmisplace any of the otherpieces: you’ll need them forsome of the projects later.❶Let’s start!Take the wood sheet and carefully separate the pieces.❹Secure your Arduino Uno to the base using 3 screws. Becareful not to overtightens.

13❷❸Go on until you’ve separated all the parts.Place the pieces marked with an “A” into the holes inthe corners, in order to create the feet of the base.❺❻Carefully peel the backing from the breadboard.Stick the breadboard on the wooden sheet, next to theArduino UNO.

14IntroductionWelcome to Arduino!-THINGS YOUNEED TOSUPPLY9V batterySmall light source like aflashlightConductive material likealuminum foil or copper meshColored paperScissorsAn old CD or DVDTape and glueA box that you can makeholes intoBasic tools like a screwdriver9V battery powered componentAny battery powered electronic device with atleast one switch or pushbutton that you’re willing to hack into will do the job.Soldering iron and solder(necessary only in Project 15)

SETTINGUPWELCOME TO ARDUINO! BEFORE YOU START CONTROLLINGTHE WORLD AROUND YOU, YOU’LL NEED TO DOWNLOAD THEIDE TO PROGRAM YOUR BOARDThe Arduino IDE allows you to write programs and upload themto your Arduino.Download the latest version of the IDE from:arduino.cc/downloadHave your Arduino board and USB cable near your computer.Don’t plug them in just yet.Follow the appropriate procedures in the next pages for Windows,Mac OS X or Linux.The online version of this guide is available at:arduino.cc/guide

16IntroductionSetting UpOnline versionWINDOWSINSTALLATIONINSTRUCTION FOR:arduino.cc/windows❶When the download of the IDE finishes, unzip the downloadedfile. Make sure to preserve the folder structure. Double-click theWINDOWS 7, VISTA,folder to open it. There should be a few files and sub-foldersAND XPinside.❷Connect the Arduino to your computer with the USB cable. YourArduino will automatically draw power from either the USB connection to the computer or an external power supply.The green power light (labeled PWR) should turn on.❸Windows should initiate its driver installation process when theboard is plugged in. Your computer won’t be able to find the drivers by itself, so you’ll need to tell it where they are located.— Click on the Start Menu and open the Control Panel.— Navigate to “System and Security”. Open the Device Manager.— In Windows XP, look for the listing named "Ports (COM & LPT)"and right click on the "USB device" port; in Vista and Windows 7,right click on "Unknown device" under "Other devices".— Choose "Update Driver Software".— On Windows XP and Windows 7, you will be asked whetherto install automatically or "with a path". Chose the second option,"with a path". On Windows Vista proceed directly to the next step.— Select the “Browse my computer for Driver software” option.— Navigate to the folder you unzipped in the earlier step.Locate and select the “Drivers” folder in the main Arduino folder(not the “FTDI USB Drivers” sub-directory). Press “OK” and “Next”to proceed.— If you are prompted with a warning dialog about not passingWindows Logo testing, click “Continue Anyway”.— Windows now will take over the driver installation.In the Device Manager, you should now see a port listing similarto “Arduino UNO (COM4)”.Congratulations! You've installed the Arduino IDE on yourcomputer.

17Online versionMAC OS XINSTALLATIONINSTRUCTION FOR:OS X 10.5 ANDLATERarduino.cc/mac❶When the download of the IDE finished, double-click the .zip fle.❷Copy the Arduino application into the Applications folder, or❸Connect the board to the computer with the USB cable. The❹You do not need to install any drivers to work with the board.This will expand the Arduino application.wherever else you wish to install the software.green power LED (labeled PWR) should turn on.Depending on the version of OS X that you are running, youmight get a dialog box asking if you wish to open the “NetworkPreferences”. Click the “Network Preferences.” button, and then❺click “Apply”.The Uno will show up as “Not Configured”, but it is still working.You can quit the System Preferences.Congratulations! You have Arduino all set up and you're ready tostart making projects.LINUXINSTALLATIONIf you’re using Linux, please visit the website for instructions:arduino.cc/linux

18IntroductionSetting UpCOMMUNICATINGWITH THEARDUINO❶Now that you’ve installed the Arduino IDE and made sure yourcomputer can talk to the board, it’s time to make sure you can upload a program.Double-click the Arduino application to open it. If the IDE loadsin the wrong language, you can change this in the applicationpreferences. Look for “Language Support” on this page for details: arduino.cc/ide❷Navigate to the LED blink example sketch ('sketch' is what Arduino programs are called). It's located under:FILE EXAMPLES 01.BASICS BLINK❸❹A window with some text in it should have opened. Leave thewindow be for now, and select your board under:TOOLS BOARD menuChoose the serial port your Arduino is connected to from theTOOLS SERIAL PORT menu.— On Windows. This is likely to be the COM with the highestnumber. There is no harm in guessing wrong, and if it doesn’twork, try the next one. To find out, you can disconnect yourArduino board and re-open the menu; the entry that disappearsshould be the Arduino board. Reconnect the board and selectthat serial port.— On Mac. This should be something with /dev/tty.usbmodemin it. There are usually two of these; select either one.Fig. 1❺To upload the Blink sketch to your Arduino, press the UPLOADtoggle in the top left corner of the window. See Fig. 1.

19❻You should see a bar indicating the progress of the upload near thelower left corner of the Arduino IDE, and the lights labeled TX andRX on the Arduino board will be blinking. If the upload is successful,the IDE will display the message DONE UPLOADING.❼A few seconds after the upload has completed, you should see theyellow LED with an L next to it start blinking. See Fig. 2.If t

Special thanks to the Fritzing team: some of the electronic com-ponents illustrations used in the book are taken or modified from the open-source Fritzing project (www.fritzing.org). Heartfelt thanks to Paul Badger for the CapacitiveSensor library used in Project 13. The text of the Arduino Projects Book is licensed under a Creative

Related Documents:

Listed under: Home Automation Projects, LED Projects, Projects 23. Bootload an Arduino with a ZIF Socket Bootloading an Arduino with a ZIF socket allows you to easily program a lot of chips at once without worrying about . 9/6/22, 2:15 PM Advanced View Arduino Projects List - Use Arduino for Projects. Projects Projects Projects. Projects .

Arduino compatible components. Personal computer running Arduino software Arduino software is free to download and use from: www.arduino.cc Arduino board Such as: Arduino Uno Freetronics Eleven Genuino Uno or any Arduino compatible board that has a standard Arduino UNO header l

Hence we given interesting top five easy to make Arduino projects with code and library link. Happy learning Arduino 1. Heart Rate Monitor AD8232 Interface Arduino 2. Fingerprint sensor-scanner with Arduino 3. Giving Voice Recognition Ability to Arduino 4. Soil Moisture Sensor and Arduino 5. How to Interface RFID with Arduino?

arduino-00 -win.zip Recommended Path c:\Program Files\ ( - version #) Step 3: Shortcut Icon Open c:\program files\arduino-00 Right Click Arduino.exe (send to Desktop (create shortcut)) \ ( - version #) Step 4: Plug In Your Arduino Plug your Arduino in: Using the included USB cable, plug your Arduino board into a free USB port. Wait for a box to .

arduino’s analog pin 4 (SDA). And the pin labelled as SCL on the MPU 6050 to the arduino’s analog pin 5 (SCL). And that’s it, you have finished wiring up the Arduino MPU 6050. Step 2: Uploading the code and testing the Arduino MPU 6050 To test the Arduino MPU 6050, first download the arduino library for MPU 6050, developed by Jeff Rowberg.

3. Then, use the Arduino IDE to write code to send to Arduino. Once a code is sent to the Arduino, it lives on the Arduino Uno. Any future edits to that code on the computer will not be sent to the Arduino unless it is manually uploaded to the Arduino Uno. When using the Arduino

117. Password access with arduino 118. Arduino Voltmeter Code 119. Easily control your iPod using Arduino 120. Candy Tossin Coffin using an Arduino 121. Arduino 7 segment Displays Digital Clock With Charlieplexing LEDs 122. Arduino controlled webcam panner 123. Binary/ Analog Clock 124. Universal Gripper

Upload your custom Arduino code with the corresponding library file 3. Add the used libraries 4. Select the used in-outputs in the Arduino IO Simulator 5. Connect the Arduino IO Simulator to the Arduino board with the right se-rial port 1. Connect the Arduino Board The Arduino IO Simulator works with a lot of