Home
Arduino Experimenter`s Guide (ARDX)
Contents
1. http n x ONN O n x For an introduct 3mm x 10mm bolt Arduino Holder x2 x1 a assembling the ee Sssepibina the Installing the IDE This is the program used to write programs for the Arduino meta It may seem a little daunting at first but once you have it installed and start playing around its secrets will reveal themselves Windows XP Step 2 Unzip the Software Unzip arduino 00 X X win zip x x version Recommended Path c Program Files Step 3 Shortcut Icon Open c program files arduino 00 X X xx version Right Click Arduino exe send to gt Desktop create shortcut 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 pop up Step 5 Add new Hardware Skip searching the internet click the next box when prompted to do so Install from a Specific destination click Install from a list or specific location Advanced Choose the Location c program files arduino 00 x x drivers FTDI USB Drivers Finished NOTE Encountering problems Would like more details Using Linux http tinyurl com r99d8u Step 1 Download the software Goto http arduino cc en Main Software And download the software for your operating system 02 INST installing software and hardware Mac OSX Step 2 U
2. pinmode clock OUTPUT pinmode latch OUTPUT void loop run over and over again int delayTime 100 delay between LED updates for int 1 0 1 lt 256 1 updateLEDS 1 delay delayTime updateLEDs sends the LED states set in value to the 74HC595 sequence void updateLEDs int value igitalwrite latch LOW Not Working 3 things to try The Arduino s Power LED goes out This happened to us a couple of times it happens when the chip is inserted backwards If you fix it quickly nothing will break Not Quite Working Making it Better Doing it the hard way An Arduino makes rather complex actions very easy shifting out data is one of these cases However one of the nice features of an Arduino is you can make things as easy or difficult as you like Lets try an example of this In your loop switch the line __ updateLEDS 1 gt updateLEDsLong 1 Upload the program and notice nothing has changed If you look at the code you can see how we are communicating with the chip one bit at a time for more details http tinyurl com 3augzd Controlling Individual LEDs Time to start controlling the LEDs in a similar method as we did in CIRCO2 As the eight LED states are stored in one byte an 8 bit value for details on how this works try http tinyurl com 6vz53 An Arduino is very good at manipulating bits and there are an entire set of operators that help us out Details on bitwis
3. 10 the time Cin milliseconds to pause between LEDS digitalwrite ledPins 0 HIGH Turns on LED 0 Cconnected to pin 2 delay delayTime waits delayTime milliseconds digitalwrite ledPins 7 HIGH Turns on LED 7 Cconnected to pin 9 I waits delayTime milliseconds Turns Each LED Of cai LOW Turns off LED 7 delay delayTime waits delayTime milliseconds Starting Afresh Its easy to accidentally misplace a wire without noticing Pulling everything out and starting with a fresh slate is often easier than trying to track down the problem Extra Animations Tired of this animation Then try the other two sample animations Uncomment their lines and upload the program to your board and enjoy the new light animations delete the slashes in front of row 3 and then 4 Testing out your own Animations Jump into the included code and start changing things The main point is to turn an LED on use digitalwrite pinNumber HIGH then to turn it off use digitalwrite pinNumber LOW Type away regardless of what you change you won t break anything Spin Motor Spin CIRC 03 l Transistor amp Motor What We re Doing The Arduino s pins are great for directly controlling small electric items like LEDs However when dealing with larger items like a toy motor or washing machine an external transistor is required A transistor is incredibly useful It swit
4. A program is nothing more than instructions to move numbers around in an intelligent way Variables are used to do the moving boolean boolean A simple True or False variable Useful because it only uses one bit of RAM void setupQ All the code between the two curly brackets will be run once when your Arduino program first runs single line comment It is often useful to write notes to yourself as you go along about what each line of code does To do this type two back Slashes and everything until the end of the line will be ignored by your program curly brackets Used to define when a block of code starts and ends used in functions as well as loops int integer The main workhorse stores a number in 2 bytes 16 bits Has no decimal places and will store a value between 32 768 and 32 768 float float Used for floating point math decimals Takes 4 bytes 32 bits of RAM and has a range between 3 4028235E 38 and 3 4028235E 38 void loopO This function is run after setup has finished After it has run once it will be run again and again until power is removed multi line comment If you have a lot to say you can span several lines as a comment Everything between these two symbols will be ignored in your program 7 semicolon Each line of code must be ended with a semicolon a missing semicolon is often the reason for a programme refusing to compile long
5. ARDX arduino experimentation kit Arduino Experimenter s Woo NO UIoO oomlout com A Few Words WOO 3 tao WOO About this Kit The overall goal of this kit is fun Beyond this the aim is to get you comfortable using a wide range of electronic components through small simple and easy circuits The focus is to get each circuit working then giving you the tools to figure out why If you encounter any problems want to ask a question or would like to know more about any part extra help is only an e mail away help oomlout com About Open Source Hardware All of oomlout s projects are open source What does this mean It means everything involved in making this kit be it this guide 3D models or code is available for free download But it goes further you re also free to reproduce and modify any of this material then distribute it for yourself The catch Quite simple it is released under a Creative Commons By Share Alike license This means you must credit oomlout in your design and share your developments in a similar manner Why We grew up learning and playing with open source software and the experience was good fun we think it would be lovely if a similar experience was possible with physical things more details on the Creative Commons CC By Share Alike License can be found at http tinyurl com 2dkzmd About oomlout We re a plucky little design company focusing on
6. H Bridge g Z ground _ More More More More details where to buy more parts where to ask more questions http tinyurl com cfagqn ARDX arduino experimentation kit www oomlout com This work is licenced under the Creative Commons Attribution Share Alike 3 0 Unported License To view a copy of this licence visit http creativecommons org licenses by sa 3 0 or send a letter to Creative Commons 171 Second Street Suite 300 San Francisco California 94105 USA
7. It has three pins ground signal and 5 volts and is easy to use It outputs 10 millivolts per degree centigrade on the signal pin to allow measuring temperatures below freezing there is a 500 mV offset eg 25 C 750 mV 0 C 500mv To convert this from the digital value to degrees we will use some of the Arduino s maths abilities Then to display it we ll use one of the IDE s rather powerful features the debug window We ll output the value over a serial connection to display on the screen Let s get to it One extra note this circuit uses the Arduino IDE s serial monitor To open this first upload the program then click the button which looks like a square with an antennae The TMP36 Ddatasheet Elie i http i tinyu rl COM pl bx38 a El Upioad to WO Board The Circuit Parts TASE gi CIRC 10 opin esd GE breadboard sheet amore Temperature Sensor a Wire x1 x4 x1 Schematic Arduino analog pin 0 precision temperature sensor SS the chip will have TMP36 printed on it ll gnd oo ground 4 APTA G AEAN ST SS of Y F 4 The Internet download printable breadboard overlay http tinyurl com ctdjod View video of the circuit being assembled http tinyurl com d85jyx Code no need to type everything in just CIRC 10 Download the Code from http tinyurl com dfj8rs copy the text and paste it into an empty Arduino Sket
8. The Circuit Potentiometer 10k ohm x1 CIRC 08 Breadboard sheet x1 560 Ohm Resistor 8 2 Pin Header x4 gt Green LED xi Green Blue Brown xi Schematic Arduino pin 13 5 volts Potentiometer diode resistor 5600hm blue green brown OW WN Mawar ground N gt A N AVIVA OW Hh TO WAVAVAYAY E i A The Internet download printable breadboard overlay http tinyurl com d6207q VIEW video of the circuit being assembled http tinvurl com cormru Code no need to type everything in just C I RC z O 8 File gt Sketchbook gt Examples gt Analog gt AnalogInput example from the great arduino cc site check it out for other great ideas AnalogInput by DojoDave lt http www 0j0 org gt Turns on and off a light emitting diode LED connected to digital time the LED will be on and off depends on l the value obtained by analogRead In the easiest case we connect a potentiometer to analog pin 2 pin 13 The amount of http ww arduino cc en Tutorial AnalogInput int potPin 2 select the input pin for the potentiometer int ledPin 13 select the pin for the LED l int val 0 variable to store the value coming from the sensor void setup pinMode ledPin OUTPUT declare the ledPin as an OUTPUT void loop val analogRead potPin digitalwrite ledPin HIGH delay val read the value from the sens
9. less than eg 12 lt 10 is FALSE or 12 lt 12 is FALSE or 12 lt 14 is TRUE gt greater than eg 12 gt 10 is TRUE or 12 gt 12 is FALSE or 12 gt 14 is FALSE 1f condition else 1f condition else This will execute the code between the curly brackets if the condition is true and if not it will test the else 1f condition if that is also false the else code will execute digitalwrite pin value Once a pin is set as an OUTPUT it can be set either HIGH pulled to 5 volts or LOW pulled to ground int analogwrite pin value Some of the Arduino s pins support pulse width modulation 3 5 6 9 10 11 This turns the pin on and off very quickly making it act like an analog output The value is any number between 0 0 duty cycle Ov and 255 100 duty cycle 5 volts for int 1 0 1 lt repeats 1 Used when you would like to repeat a chunk of code a number of times can count up i or down i or use any variable int digitalRead pin Once a pin is set as an INPUT you can use this to return whether it is HIGH pulled to 5 volts or LOW pulled to ground int analogRead pin When the analog input pins are set to input you can read their voltage A value between 0 for 0 volts and 1024 for 5 volts will be returned Edo electronics primer Electronics in Brief No previous electronic experience is required to have fun with this kit
10. 5 analogwrite ledPin lightLevel write the value int lightLevel Frustration Shoot us an e mail this circuit is both simple and complex at the same time We want to hear about problems you have so we can address them in future editions help oomlout com Light controlled servo Lets use our newly found light sensing skills to control a servo and at the same time engage in a little bit of Arduino code hacking Wire up a servo connected to pin 9 like in CIRC 04 Then open the Knob example program the same one we used in CIRC 08 File gt Sketchbook gt Examples gt Library Servo gt Knob Upload the code to your board and watch as it works unmodified Using the full range of your servo You ll notice that the servo will only operate over a limited portion of its range This is because with the voltage dividing circuit we use the voltage on analog pin 0 will not range from 0 to 5 volts but instead between two lesser values these values will change based on your setup To fix this play with the val map val 0 1023 0 179 line For hints on what to do visit http arduino cc en Reference Map CIRC 10 T emperature TMP36 Precision Temperature Sensor What We re Doing What s the next phenomena we will measure with our Arduino Temperature To do this we ll use a rather complicated IC integrated circuit hidden in a package identical to our 2N222A transistors
11. C z O 6 File gt Sketchbook gt Examples gt Digital gt Melody example from the great arduino cc site check it out for other great ideas Melody i cleft 2005 D Cuartielles for K3 This example uses a piezo speaker to play melodies It sends digitalwrite speakerPin LOW a square wave of the appropriate frequency to the piezo delayMicroseconds tone generating the corresponding tone The calculation of the tones is made following the mathematical operation void playNote char note int duration pid char names pa I I rz Sa al b ne timeHigh period 2 1 2 toneFrequency int tones 1915 1700 1519 1432 1275 1136 1014 956 where the different tones are described as in the table play the tone corresponding to the note name l l for Cint i 0 i lt 8 i ote frequency period timeHigh if names i note 261 Hz 3830 1 playTone tones i duration void setup pinMode speakerPin OUTPUT n C d e f p ag a b C http ww arduino cc en Tutorial Melody void loop ay for int i 0 i lt length i if notes i delay beats i tempo rest else playNote notes i beats i tempo ida ey 4 48 pause between notes delay tempo 2 void playTone int tone int duration for long i 0 i lt duration 1000L i tone 2 digitalwrite speakerPin HIGH delayMicroseconds tone Not W
12. Here are a few details A Small Electronics Primer about each component to make identifying and perhaps understanding them a bit easier If at Component Details LED Light Emitting Diode Diode o Resistors Ga ed Transistor Hobby Servo What it Does Emits light when a small current is passed through it only in one direction Identifying Looks like a mini light bulb What it Does The electronic equivalent of a one way valve Allowing current to flow in one direction but not the other Identifying Usually a cylinder with wires extending from either end and an off center line indicating polarity What it Does Restricts the amount of current that can flow through a circuit Identifying Cylinder with wires extending from either end The resistance value is displayed using a color coding system for details see next page What it Does Uses a small current to switch or amplify a much larger current Identifying Comes in many different packages but you can read the part number off the package 2N222A in this kit and find a datasheet online What it Does Takes a timed pulse and converts it into an angular position of the output shaft Identifying A plastic box with 3 wires coming out one side and a shaft with a plastic horn out the top What it Does Spins when a current is passed through it Identifying This one is easy it looks like
13. Pin Header Pe Pushbutton Breadboard sheet INN gt r X Wire x4 x1 10k Ohm Resistor 560 Ohm Resistor Brown Black Red Vai Green Blue Brown Red LED x2 x1 xi na Arduino Schematic n2 ine Arduino 5 volts pin 13 resistor LED 10k ohm light emitting brown black red diode resistor 5600hm blue green brown a 7 TANT J A i VV LTP BT 7 RR 5 K ground The Internet download printable breadboard overlay http tinyurl com dzmh8w VIEW video of the circuit being assembled http tinyurl com dnin6g Code no need to type everything in just I RC O L File gt Sketchbook gt Examples gt Digital gt Button example from the great arduino cc site check it out for other great ideas Button by DojoDave lt http ww 0 0 org gt Turns on and off a light emitting diode LED connected to digital pin 13 when pressing a pushbutton attached to pin 7 http ww arduino cc en Tutor1al Button int ledPin 13 int inputPin 2 int val 0 choose the pin for the LED choose the input pin for a pushbutton variable for reading the pin status void setup pinMmode ledPin pinMode inputPin OUTPUT declare LED as output INPUT declare pushbutton as input void loop val digitalRead inputPin read input value 1f val HIGH check 1f the input 1S HIGH I alle eal LOW turn LED OFF else digitalwrite l
14. a motor Usually a cylinder with a shaft coming out of one end any point you are worried about how a component is used or why its not working the internet offers a treasure trove of advice or we can be contacted at help oomlout com No of Leads 2 one longer this one connects to positive Things to watch out for Will only work in one direction Requires a current limiting resistor More Details on Wikipedia http tinyurl com zhpyv No of Leads 2 Things to watch out for Will only work in one direction current will flow if end with the line is connected to ground More Details on Wikipedia http tinyurl com ysz57b No of Leads 2 Things to watch out for Easy to grab the wrong value double check the colors before using More Details on Wikipedia http tinyurl com cmeqw5 No of Leads 3 Base Collector Emitter Things to watch out for Plugging in the right way round also a current limiting resistor is often needed on the base pin More Details on Wikipedia http tinyurl com eazkn No of Leads 3 Things to watch out for The plug is not polarized so make sure it is plugged in the right way More Details http tinyurl com 4zo4he No of Leads 2 Things to watch out for Using a transistor or relay that is rated for the size of motor you re using More Details on Wikipedia http tinyurl com d826yh Component Details cont Piezo Element What it Does A pulse
15. a second digitalwrite ledPin LOW sets the LED off delay 1000 waits for a second Not Working 3 things to try Not Quite Working No Clicking Sound The included relays are designed to be soldered rather than used in a breadboard As such you may need to press it in to ensure it works and it may pop out occasionally Nothing Happens The example code uses pin 13 and we have the relay connected to pin 2 Make sure you made this change in the code The transistor or coil portion of the circuit isn t quite working Check the transistor is plugged in the right way Making it Better Controlling a Motor In CIRC 03 we controlled a motor using a transistor However if you want to control a larger motor a relay is a good option To do this simply remove the red LED and resistor 2 2kohm connect the motor in its place remember to bypass the SER 560 Ohm resistor Se Controlling Motor Direction a A bit of a complicated improvement to finish To control the direction of spin of a DC motor we must be able to reverse the direction of current flow through it To do this manually we reverse the leads To do it electrically we require something called an h bridge It can be constructed using either four transistors 2 PNP and 2 NPN or using one DPDT relay To control the motor s direction wire up the following circuit It looks complicated but can be accomplished using only a few extra wires Give it a try DPDT Relay
16. a small gearbox to make the movement more powerful and some electronics to make it easier to control A standard servo is positionable from 0 to 180 degrees Positioning is controlled through a timed pulse between 1 25 milliseconds 0 degrees and 1 75 milliseconds 180 degrees 1 5 milliseconds for 90 degrees Timing varies between manufacturer If the pulse is sent every 25 50 milliseconds the servo will run smoothly One of the great features of the Arduino is it has a software library that allows you to control two servos connected to pin 9 or 10 using a single line of code A Single Servo Servos 2 Pin Header 3 Pin Header x4 x1 rs Wire Code no need to type everything in just C I RC z o4 File gt Sketchbook gt Examples gt Library Servo gt Sweep example from the great arduino cc site check it out for other great ideas Sweep by BARRAGAN lt http barraganstudio com gt include lt Servo h gt l Servo myservo create servo object to control a servo Int pos 0 variable to store the servo position void setup myservo attach 9 attaches the servo on pin 9 to the servo object void loop for pos 0 pos lt 180 pos 1 goes from 0 degrees to 180 degrees in steps of 1 degree myservo write pos delay 15 oo ee 180 pos gt 1 pos 1 myservo write pos delay 15 Not Working 3 things to try Servo Not Twisting Even
17. be inserted 90 degrees off angle More Details http tinyurl com cmts7d No of Leads 3 Things to watch out for Accidentally buying logarithmic scale More Details http tinyurl com 28pbhd No of Leads 2 Things to watch out for Remember it needs to be in a voltage divider before it provides a useful input More Details http tinyurl com c2wdkw Resistor Color Code Lead Clipping Some components in this kit come with very long wire leads To make them more compatible with a breadboard a couple of changes are required LEDs Clip the leads so the long lead is 7mm long and the short one is 5mm Resistors Examples green blue brown 560 ohms red red red 2 200 ohms 2 2k brown black orange 10 000 ohms 10k tolerance Bend the leads down so they are 90 degrees to the cylinder Then snip them so they are 6mm long Other Components Other components may need clipping use your discretion when doing so 0 Black 1 Brown 2 Red 3 Orange 4 Yellow 20 none 10 silver 5 gold 5 Green 6 Blue 7 Purple 8 Grey 9 White Getting Started Blinking LED CIRC O01 What We re Doing LED s light emitting diodes are used in all sorts of clever things which is why we have included them in this kit We will Start off with something very simple turning one on and off repeatedly producing a pleasant blinking effect To get started grab the parts l
18. ch Arduino Experimentation Kit Example Code CIRC 10 Temperature A simple program to output the current temperature to the IDE s debug window For more details on this circuit http tinyurl com c89tvd TMP36 Pin Variables 7 nt temperaturePin 0 the analog pin the TMP36 s Vout pin is connected to the resolution is 10 mv degree centigrade 500 mv offset to make negative temperatures an option void setup void loop serial begin 9600 Start the serial connection with the copmuter to view the result open the serial monitor l ast button beneath the file bar Clooks like a box with an antenae run over and over again Not Working 3 things to try Nothing Seems to Happen This program has no outward indication it is working To see the results you must open the Arduino IDE s serial monitor instructions on previous page temperature delay 1000 This happens because the serial monitor is receiving data at a different speed than expected To fix this click the pull down box that reads baud and float temperature getvoltage temperaturePin getting the voltage reading from the temperature sensor temperature 5 100 converting from 10 mv per degree wit 500 mv offset to degrees volatge 500mv times 100 Serial println temperature printing the result waiting a second getvoltage retur
19. ches a lot of current using a much smaller current A transistor has 3 pins For a negative type NPN transistor you connect your load to collector and the emitter to ground Then when a small current flows from base to the emitter a current will flow through the transistor and your motor will spin this happens when we set our Arduino pin HIGH There are literally thousands of different types of transistors allowing every situation to be perfectly matched We have chosen a 2N222A a rather common general purpose transistor The important factors in our case are that its maximum voltage 40 v and its maximum current 600 milliamp are both high enough for our toy motor full details can be found on its datasheet http tinyurl com o2cm93 The 1N4001 diode is acting as a flyback diode for details on why its there visit http tinyurl com b559mx The Circuit CIRC 03 Transistor 2 Pin Header i Breadboard sheet sd 2N2222A T092 FOX Wire x1 xi 2 2k Ohm Resist a Toroi Diode Red Red Red D E 1N4001 x1 x x1 the transistor will have 2N222A printed on it some variations will have 4 the pin assignment reversed Schematic Arduino pin 9 resistor 2 2kohm red red red Transistor ground 5 volts ORE op Pp Pp The Internet download printable breadboard overlay http tinyurl com d6jv63 View video of the circuit being assembled http tinyurl com djapj Code no need
20. e maths http tinyurl com br8dd Our implementation Replace the 1oop code with int delayTime 100 the number of More More More http Sorry to sound like a broken record but it is probably something as simple as a crossed wire More details where to buy more parts where to ask more questions tinyurl com dkjino3 Pulls the chips latch low shiftout data clock MSBFIRST value Shifts out 8 bits to the shift register digitalwrite latch HIGH Pulls the latch high displaying the data Frustration Shoot us an e mail this circuit is both simple and complex at the same time We want to hear about problems you have so we can address them in future editions help oomlout com milliseconds to delay between LED updates for int i 0 1 lt 8 1 changeLED 1 ON delay delayTime for int i 0 i lt 8 1 changeLED 1 OFF delay delayTime And upload this will cause the lights to light up one after another and then off in a similar manner Check the code and wikipedia to see how it works or shoot us an e mail if you have questions More Animations Now things get more interesting If you look back to the code from CIRC02 8 LED Fun you see we change the LEDs using digitalWrite led state this is the same format as the routine we wrote changeLED led state You can use the animations you wrote for CIRC02 by copying the code into this sketch and changing a
21. edPin HIGH turn LED ON Not Working 3 things to try Light Not Turning On Light Not Fading Underwhelmed The pushbutton is square and because of this it is easy to put it in the wrong way Give it a 90 degree twist and see if it starts working No worries these circuits are all Super stripped down to make playing with the components easy but once you throw them together the sky is the limit A bit of a silly mistake we constantly made when you switch from simple on off to fading remember to move the LED wire from pin 13 to pin 9 Making it Better On button off button Fading up and down The initial example may be a little underwhelming ie I don t really need an Arduino to do this lets make it a little more complicated One button will turn the LED on the other will turn the LED off Change the code to int ledPin 13 choose the pin for the LED int inputPinl 3 button 1 int inputPin2 23 button 2 void setup pinMode ledPin pinMode inputPin1 pinMode inputPin2 OUTPUT declare LED as output INPUT make button 1 an input INPUT make button 2 an input void loop if digitalRead inputPin1 LOW digitalwrite ledPin LOW turn LED OFF else if digitalRead inputPin2 LOW digitalwrite ledPin HIGH turn LED ON Upload the program to your board and start toggling the LED on and off More More More htt More details where to buy mo
22. ged in backwards void loopd int pulseTime 2100 the number of microseconds to pause for 1500 90 degrees 900 0 degrees 2100 180 degrees digitalwrite servoPin HIGH delayMicroseconds pulseTime digitalwrite servoPin LOW delay 25 Great Ideas Servos can be used to do all sorts of great things here are a few of our favorites Xmas Hit Counter http tinyurl com 37djhq Open Source Robotic Arm uses a servo controller as well as the Arduino http tinyurl com ckm3wd Servo Walker http tinyurl com da5jfe CIRC 05 8 More LED s 74HC595 Shift Register What We re Doing Time to start playing with chips Or integrated circuits ICs as they like to be called The external packaging of a chip can be very deceptive for example the chip on the Arduino board a micro controller and the one we will use in this circuit a shift register look very similar but are in fact rather different for example the price of the Atmega chip on the arduino board is a few dollars while the 74hc595 is a couple dozen cents It s a good introductory chip and once your comfortable playing around with it and its datasheet available online http tinyurl com pr42xe the world of chips will be your oyster The shift register also called a serial to parallel converter will give you an additional 8 outputs to control LEDs and the like using only four arduino pins They can also be li
23. ging variables easier its a group of variables The Circuit x4 CIRC 02 2 Pin Header 5mm GreenLED Breadboard sheet x8 na Wire x1 560 Ohm Resistor Green Blue Brown x8 Schematic Arduino Arduino Arduino Arduino pin 2 in 3 in 4 in 5 p p p LED gt gt gt SS light emitting diode resistor 5600hm blue green brown gnd ground Arduino Arduino Arduino Arduino pin in in in 9 6 pin 7 pin 8 pi LED gt gt gt light emitting diode resistor 5600hm blue green brown gnd TEN ground i NN gt EY ae im gt n o IH O N WA JR O N Y ZIA III RAZ LOR GO a lt n ND T soi VOGA A et OY dA Aa d Q amp e x AOGA k OEO OXA DA ODA MRO The Internet download printable breadboard overlay http tinyurl com d4gmov VIEW video of the circuit being assembled http tinyurl com coafoh Code no need to type everything in just I RC ET O 2 Download the Code from http tinyurl com dkpxbn and then copy the text and paste it into an empty Arduino Sketch LED Pin Variables int ledPins 2 3 4 5 6 7 8 9 An array to hold the pin each LED is connected to 1 e LED 0 1S connected to pin 2 void setup for int 1 0 1 lt 8 i this is a loop and will repeat eight times pinmode ledPins 1 OUTPUT we use t
24. his to set LED pins to output l void loop run over and over again oneAfterAnotherNoLoop this will turn on each LED one by one then turn each oneoff oneAfterAnotherLoop this does the same as onAfterAnotherNoLoop but with much less typing oneOnAtATime inAndout oneAfterAnotherNoLoop will light one then delay for delayTime then light the next LED it Not Working 3 things to try Some LEDs Fail to Light It is easy to insert an LED backwards Check the LEDs that aren t working and ensure they the right way around Making it Better Switching to Loops in the loop function there are 4 lines The last three all start with a this means the line is treated as a comment not run To switch the program to use loops change the void loop code to oneAfterAnotherNoLoop oneAfterAnotherLoop oneOnAtATime inAndout Upload the program and notice that nothing has changed You can take a look at the two functions each does the same thing but use different approaches hint the second one uses a for loop More More More htt Operating out of sequence With eight wires it s easy to cross a couple Double check that the first LED is plugged into pin 2 and each pin there after More details where to buy more parts where to ask more questions tinyurl com d2hrud will then turn them off void oneAfterAnotherNoLoop Int delayTime
25. ink e Twinkie Little star the top of the program But to tune individual notes just char notes ccggaagffeeddc l int beats 1 1 1 1 1 1 2 1 1 1 1 adjust their values in the tones array up or down until they sound right each note is matched by its name Hap Birthday first line in the names array ie c 1915 char notes ccdcfeccdcgf i int beats 1 1 1 1 1 2 1 1 1 1 1 2 4 C More More More More details where to buy more parts where to ask more questions http tinyurl com cpf6so Button Pressing Pushbuttons CIRC 0 7 What We re Doing Up to this point we have focused entirely on outputs time to get our Arduino to listen watch and feel We ll start with a simple pushbutton Wiring up the pushbutton is simple There is one component the pull up resistor that might seem out of place This is included because an Arduino doesn t sense the same way we do ie button pressed button unpressed Instead it looks at the voltage on the pin and decides whether it is HIGH or LOW The button is set up to pull the Arduino s pin LOW when it is pressed however when the button is unpressed the voltage of the pin will float causing occasional errors To get the Arduino to reliably read the pin as HIGH when the button is unpressed we add the pull up resistor note the first example program uses only one of the two buttons The Circuit CIRCO m 2
26. isted below pin the layout sheet to your breadboard and then plug everything in Once the circuit is assembled you ll need to upload the program To do this plug the Arduino board into your USB port Then select the proper port in Tools gt Serial Port gt the comm port of your Arduino Next upload the program by going to File gt Upload to I O Board ctrl U Finally bask in the glory and possibility that controlling lights offers If you are having trouble uploading a full trouble shooting guide can be found here http tinyurl com 89s2po The Circuit po SE m 2 Pin Header 10mm LED Breadboard sheet sa da di x1 Fx Wire x1 560 Ohm Resistor Green Blue Brown xi Schematic Arduino pin 13 LED light emitting diode resistor 5600hm blue green brown gnd ground The Internet download printable breadboard overlay http tinyurl com qukhvc View video of the circuit being assembled http tinyurl com cwhx27 9 Onda EA ANI WAVE avi we N Yer Code no need to type everything in just File gt Sketchbook gt Examples gt Digital gt Blink example from the great arduino cc site check it out for other ideas Blink The basic Arduino example then off for one second and so on Turns an LED on for one second We use pin 13 because depending on your Arduino board it has either a built in LED or a built in resistor so that you need onl
27. its there visit http tinyurl com b559mx The Circuit s CIRC 11 Transistor Relay a 2 Pin H a D Seaboard sheet in Header 2N222A TO92 ad DPDT xi x4 x1 x1 2 2k Ohm Resistor 560 Ohm Resistor ad Red Red Red P Green Blue Brown Green LED Red LED x1 x1 Diode 1N4001 x1 Schematic Arduino resistor 2 2kohm red red red 5 Transistor the transistor will have 2N222A printed on it some variations will have the pin assignment reversed g ground _ The Internet download printable breadboard overlay http tinyurl com cxpvgq View video of the circuit being assembled http tinyurl com chf7rx Code no need to type everything in just C I RC 1 1 File gt Sketchbook gt Examples gt Digital gt Blink example from the great arduino cc site check it out for other great ideas Blink The basic Arduino example Turns on an LED on for one second then off for one second and so on We use pin 13 because depending on your Arduino board it has either a built in LED or a built in resistor so that you need only an LED a eee een een int ledPin 2 BRRRRREEEEX CHANGE TO PIN 2 888 kikiki void setup run once when the sketch starts pinMode ledPin OUTPUT sets the digital pin as output loop run over and over again digitalwrite ledPin HIGH sets the LED on delay 1000 waits for
28. ll the digitalWrite s to changeLED s Powerful Very you ll also need to change a few other things but follow the compile errors and it works itself out IMUSIC Piezo Elements CIRC 06 What We re Doing To this point we have controlled light motion and electrons Lets tackle sound next But sound is an analog phenomena how will our digital Arduino cope We will once again rely on its incredible speed which will let it mimic analog behavior To do this we will attach a piezo element to one of the Arduino s digital pins A piezo element makes a clicking sound each time it is pulsed with current If we pulse it at the right frequency ie quickly enough these clicks will run together to produce notes Lets get to experimenting with it and get your Arduino playing Twinkle Twinkle Little Star The Circuit Parts i CIRC 06 a 4 2 Pin Header Piezo Element SS Breadboard sheet x4 xi CO Wire x1 Schematic Arduino pin 9 Piezo Element gnd ground i 1 The Internet download printable breadboard overlay http tinyurl com c94aml View video of the circuit being assembled http tinyurl com mnh330 int speakerPin 9 int length 15 the number of notes char notes ccggaagffeeddc a space represents a rest int beats 1 1 1 Li 1 1 2 1 1 1 1 int tempo 300 Code no need to type everything in just C I R
29. long Used when an integer is not large enough Takes 4 bytes 32 bits of RAM and has a range between 2 147 483 648 and 2 147 483 648 char character Stores one character using the ASCII code ie A 65 Uses one byte 8 bits of RAM The Arduino handles strings as an array of char s For a full programming reference visit http tinyurl com 8820xm Maths Operators Operators used for manipulating numbers they work like simple maths 03 PROG gt il golely iseiaeiiale primer assignment makes something equal to something else eg x 10 2 x now equals 20 modulo gives the remainder when one number is divided by another ex 12 10 gives 2 addition subtraction multiplication division Comparison Operators Operators used for logical comparison Control Structure Programs are reliant on controlling what runs next here are the basic control elements there are many more online Digital pinMode pin mode Used to set a pins mode pin is the pin number you would like to address 0 19 analog 0 5 are 14 19 the mode can either be INPUT or OUTPUT The Arduino is a digital machine but it has the ability to operate in the analog realm through tricks Here s how to deal with things that aren t digital equal to eg 12 10 is FALSE or 12 12 is TRUE I not equal to eg 12 10 is TRUE or 12 12 is FALSE lt
30. milliseconds Still Not Working Sometimes the Arduino board will disconnect from the computer Try un plugging and then re plugging it into your USB port In the loop section change it to this motorOnThenofFfQ motorOnThenoffwithSpeedQ motorAcceleration Then upload the programme You can change the speeds by changing the variables onSpeed and offSpeed Accelerating and decelerating Why stop at two speeds why not accelerate and decelerate the motor To do this simply change the loop code to read motoronThenoff yy motoronThenoffwithSpeed motorAcceleration Then upload the program and watch as your motor slowly accelerates up to full speed then slows down again If you would like to change the speed of acceleration change the variable delayTime larger means a longer acceleration time CIRC 04 The Circuit CIRC 04 Breadboard sheet xi Mini Servo x1 Schematic Arduino pin 9 Mini Servo gnd ground _ 5 volts 5V The Internet download printable breadboard overlay http tinyurl com db5fcm Vview video of the circuit being assembled http tinyurl com d52954 What We re Doing Spinning a motor is good fun but when it comes to projects where motion control is required they tend to leave us wanting more The answer Hobby servos They are mass produced widely available and cost anything from a couple of dollars to hundreds Inside is
31. n OUTPUT sets the led pin to output Not Working 3 things to try LED is Remaining Dark This is a mistake we continue to make time and time again if only they could make an LED that worked both ways Pull it up and give it a twist Making it Better Reverse the response Perhaps you would like the opposite response Don t worry we can easily reverse this response just change analogwrite ledPin lightLevel gt analogwrite ledPin 255 lightLevel upload and watch the response change Night light Rather than controlling the brightness of the LED in response to light lets instead turn it on or off based on a threshold value Change the loop code with void loop int threshold 300 1f analogRead lightPin gt threshold digitalwrite ledPin HIGH else digitalwrite ledPin LOW More More More http It Isn t Responding to Changes in Light Given that the spacing of the wires on the photo resistor is not standad it is easy to misplace it Double check its in the right place More details where to buy more parts where to ask more questions tinyurl com cpa83c 5 sl loop this function will start after setup finishes and then repeat void loop analogRead lightPin Read the ightlevel lightLevel map lightLevel 0 900 0 255 adjust the value 0 to 900 to lightLevel constrain lightLevel 0 255 make sure the value is betwween 0 and 25
32. nked together to give you a nearly unlimited number of outputs using the same four pins To use it you clock in the data and then latch it To do this you set the data pin to either HIGH or LOW pulse the clock then set the data pin again and pulse the clock repeating until you have shifted out 8 bits of data Then you pulse the latch and the 8 bits are transferred to the shift registers pins It sounds complicated but is really simple once you get the hang of it for a more in depth look at how a shift register works visit http tinyurl com 56uvv7 The Circuit Parts Shift Register gi CIRC 05 gt L 2 Pin Header gt 74HC595 ko Breadboard sheet x4 0 si N Wire x1 560 Ohm Resistor Red LED x8 Green Blue Brown x8 Schematic Arduino 5 volts pin 4 pin 3 pin 2 blue green brown resistor 5600hm There is a half moon cutout this goes at the top LETTE 4 Ti Ibi VAI 4 The Internet download printable breadboard overlay http tinyurl com d8xepz View video of the circuit being assembled http tinyurl com c2enkv Code no need to type everything in just CIRC 05 Download the Code from http tinyurl com cv4fjt copy the text and paste it into an empty Arduino Sketch Pin Definitions The 74HC595 uses a protocol called SPI which has three pins int data 2 int clock int latch 3 4 void setup runs once pinMode data OUTPUT
33. ns the voltage on the analog input defined by pin float getvoltage int pin return analogRead pin 004882814 converting from a 0 to 1024 digital range to 0 to 5 volts each 1 reading equals 5 millivolts Gibberish is Displayed Temperature Value is Unchanging Wrong This will happen if the LM35 is plugged in backwards Look carefully at the layout sheet change it to 9600 baud Making it Better Outputting voltage This is a simple matter of changing one line Our sensor outputs 10mv per degree centigrade so to get voltage we simply display the result of getVoltage delete the line temperature temperature 5 100 Outputting degrees Fahrenheit Again this is a simple change requiring only math to go degrees C gt degrees F we use the formula F C 1 8 32 add the line temperature temperature 5 100 1 8 32 before Serial println temperature More informative output Lets add a message to the serial output to make what is appearing in the Serial Monitor more informative To do More More More http More details where to buy more parts where to ask more questions tinyurl com c89tvd this first revert to the original code then change Serial println temperature Serial print temperature Serial println degrees centigrade The change to the first line means when we next output it will appear on the same line then we add the inf
34. nzip the Software Unzip double click arduino 00 X X mac zip x x version Move Folder move arduino 00 X X to Applications Step 3 Alias Icons Open Applications arduino 00 X X xx version Command Click Make Alias Drag to Desktop Step 4 Install Drivers Goto Applications Arduino 00 x x drivers Double Click amp Install FTDIUSBSerialDriver V2 2 9 Intel dmg V2_1_9 dmg if not an Intel Mac Restart Step 5 Plug In Your Arduino Plug your Arduino in using the included USB cable plug your Arduino board into a free USB port 03 PROG i golelg lseiaaiiaie primer A Small Programming Primer Arduino Programming in Brief The Arduino is programmed in the C language This is a quick little primer targeted at people who have a little bit of programing experience and just need a briefing on the ideosyncrocies of C and the Arduino IDE If you find the concepts a bit daunting don t worry you can start going through the circuits and pick up most of it along the way For a more in depth intro the Arduino cc website is a great resource the foundations page http tinyurl com 954pun Structure Each Arduino program often called a sketch has two required functions also called routines One of the slightly frustrating elements of C is its formating requirements this also makes it very powerful If you remember the following you should be alright Variables
35. of current will cause it to click a stream of pulses will cause it to emit a tone Identifying In this kit it comes in a little black barrel but sometimes they are just a gold disc IC Integrated Circuit What it Does Packages any range of complicated electronics inside an easy to use form factor Identifying The part ID is written on the outside of the package this sometimes requires a lot of light or a magnifying glass to read Pushbutton What it Does Completes a circuit when it is pressed Identifying A little square with leads out the bottom and a button on the top Potentiometer What it Does Produces a variable resistance dependant on the angular position of the shaft Identifying They can be packaged in many different form factors look for a dial to identify Photo Resistor What it Does Produces a variable resistance dependant on the amount of incident light Identifying Usually a little disk with a clear top and a curvy line underneath 04 ELEC electronics primer No of Leads 2 Things to watch out for Difficult to misuse More Details http tinyurl com 38crmu No of Leads 2 100s in this kit there is one with 3 TMP36 and one with 16 74HC595 Things to watch out for Proper orientation look for marks showing pin 1 More Details http tinyurl com 87k4d No of Leads 4 Things to watch out for these are almost square so can
36. or turn the ledPin on stop the program for some time turn the ledPin off digitalwrite ledPin LOW delay val Not Working 3 things to try Sporadically Working There are two ways to fix this either switch the red and black wires connected to the potentiometer or turn the potentiometer around sorry sometimes the factory ships us a This is most likely due to a slightly dodgy connection with the potentiometer s pins This can usually be conquered by taping the potentiometer down stop the program for some time The Control is Backward Still Backward You can try operating the circuit upside down Sometimes this helps backwards potentiometer Making it Better Threshold Switching Sometimes you will want to switch an output when a value exceeds a certain threshold To do this with a potentiometer change the loop code to void loop int threshold 512 if analogRead potPin gt threshold digitalwrite ledPin HIGH else digitalwrite ledPin LOW This will cause the LED to turn on when the value is above 512 about halfway you can adjust the sensitivity by changing the threshold value Fading Lets control the brightness of an LED directly from the potentiometer To do this we need to first change the pin the LED is connected to Move the wire from pin 13 to pin 9 and change one line in the code int ledPin 13 gt int ledPin 9 More More More http Mo
37. orking 3 things to try Tired of Twinkle Twinkle No Sound Can t Think While the Little Star Given the size and shape of the Melody is Playing piezo element it is easy to miss l the right holes on the Just pull up the piezo element easily add your own songs breadboard Try double whilst you think upload your siaa a Dew tg checking its placement program then plug it back in get started The code is written so you can Making it Better Playing with the speed char names The timing for each note is calculated based on variables ASA defi 1915 1700 1519 1432 1275 1136 as such we can tweak the sound of each note or the 1014 956 timing To change the speed of the melody you need to Composing your own melodies change only one line The program is pre set to play Twinkle Twinkle Little Star int tempo 300 gt int tempo new however the way it is programmed makes changing the song Change it to a larger number to slow the melody down 9 9 i 7 easy Each song is defined in one int and two arrays the 1nt or a smaller number to speed it up 1 h defines th ternate ia ft Tuning the notes ength defines the number of notes the first array notes If you are worried about the notes being a little out of defines each note and the second beats defines how long tune this can be fixed as well The notes have been each note is played Some Examples calculated based on a formula in the comment block at Tw
38. ormative text and a new line Changing the serial speed If you ever wish to output a lot of data over the serial line time is of the essence We are currently transmitting at 9600 baud but much faster speeds are possible To change this change the line Serial begin 9600 gt Serial begin 115200 Upload the sketch turn on the serial monitor then change the speed from 9600 baud to 115200 baud in the pull down menu You are now transmitting data 12 times faster Larger Loads Relays CIRC 11 What We re Doing The final circuit is a bit of a test We combine what we learned about using transistors in CIRC03 to control a relay A relay is an electrically controlled mechanical switch Inside the little plastic box is an electromagnet that when energized causes a switch to trip often with a very satisfying clicking sound You can buy relays that vary in size from a quarter of the size of the one in this kit up to as big as a fridge each capable of switching a certain amount of current They are immensely fun because there is an element of the physical to them While all the silicon we ve played with to this point is fun sometimes you just want to wire up a hundred switches to control something magnificent Relays give you the ability to dream it up then control it with your Arduino Now to using todays technology to control the past The 1N4001 diode is acting as a flyback diode for details on why
39. producing delightfully fun open source products To check out what we are up to http www oomlout com About Problems We strive to deliver the highest level of quality in each and every thing we produce If you ever find an ambiguous instruction a missing piece or would just like to ask a question we ll try our best to help out You can reach us at help oomlout com we like hearing about problems it helps us improve future versions Thanks For Choosing oomlout Tiferems NOJUOO oomlout com Where to Find Everything Before We Start ASEM INST PROG ELEC Assembling the Pieces Installing the Software A Small Programming Primer A Small Electronics Primer The Circuits CIRCO1 CIRC02 CIRCO3 CIRC04 CIRCO5 CIRCO6 CIRCO7 CIRCO8 CIRC09 CIRC10 CIRC11 Getting Started Blinking LED 8 LED Fun Multiple LEDS Spin Motor Spin Transistor and Motor A Single Servo Servos 8 More LEDs 74HC595 Shift Register Music Piezo Elements Button Pressing Pushbuttons Twisting Potentiometers Light Photo Resistors Temperature TMP36 Temperature Sensor Larger Loads Relays TBCN table of contents 02 03 04 06 08 10 12 14 16 18 20 22 24 26 28 Arduino J a Le 2005 7 n EE ino is visi ing It Together Bicadbeard xjmh iii x4 to what an Ardu neama limi
40. re details where to buy more parts where to ask more questions tinyurl com cva3k Then change the loop code to void loop int value analogRead potPin 4 analogwrite ledPin value Upload the code and watch as your LED fades in relation to your potentiometer spinning Note the reason we divide the value by 4 is the analogRead function returns a value from 0 to 1024 10 bits and analogWrite takes a value from 0 to 255 8 bits Controlling a Servo This is a really neat example and brings a couple of circuits together Wire up the servo like you did in CIRC 04 then open the example program Knob File gt Sketchbook gt Examples gt Library Servo gt Knob then change one line of code int potpin 0 gt int potpin 2 Upload to your Arduino and then watch as the servo shaft turns as you turn the potentiometer Light Photo Resistors CIRC 09 What We re Doing Whilst getting input from a potentiometer can be useful for human controlled experiments what do we use when we want an environmentally controlled experiment We use exactly the same principles but instead of a potentiometer twist based resistance we use a photo resistor light based resistance The Arduino cannot directly sense resistance it senses voltage so we set up a voltage divider http tinyurl com 2sunta The exact voltage at the sensing pin is calculable but for our purposes just sensing
41. re parts where to ask more questions tinyurl com c64tmt Lets use the buttons to control an analog signal To do this you will need to change the wire connecting the LED from pin 13 to pin 9 also change this in code int ledPin 13 gt int ledPin 9 Next change the loop code to read int value 0 void loop if CdigitalReadC inputPinl LOW value else if digitalRead inputPin2 LOW value value constrain value 0 255 analogwrite ledPin value delay 10 Changing Fade Speed If you would like the LED to fade faster or slower there is only one line of code that needs changing delay 10 gt delay new To fade faster make the number smaller slower requires a larger number sTwisting Potentiometers CIRC 08 What We re Doing Along with the digital pins the Arduino has it also has 6 pins which can be used for analog input These inputs take a voltage from 0 to 5 volts and convert it to a digital number between 0 0 volts and 1024 5 volts 10 bits of resolution A very useful device that exploits these inputs is a potentiometer also called a variable resistor When it is connected with 5 volts across its outer pins the middle pin will read some value between 0 and 5 volts dependent on the angle to which it is turned ie 2 5 volts in the middle We can then use the returned values as a variable in our program
42. relative light we can experiment with the values and see what works for us A low value will occur when the sensor is well lit while a high value will occur when it is in darkness The Circuit CIRC 10 2 Pin Header Photo Resistor Breadboard sheet xi CN Wire xi 10k Ohm Resistor 560 Ohm Resistor Brown Black Red Green Blue Brown Green LED xi x1 xi Schematic Arduino pin 13 5 volts 2 photo Z resistor LED N light emitting diode resistor 5600hm gnd LEI ground TTEUETqMWYE ext O The Internet download printable breadboard overlay http tinyurl com cmzfdu VIEW video of the circuit being assembled http tinyurl com cdidd6 Code no need to type everything in just CIRC 09 Download the Code from http tinyurl com crdume copy the text and paste it into an empty Arduino Sketch A simple programme that will change the intensity of an LED based on the amount of light incident on the photo resistor ale PAS PhotoResistor Pin int lightPin 0 the analog pin the photoresistor is connected to the photoresistor is not calibrated to any units so this 1S simply a raw sensor value relative light LED Pin int ledPin 9 the pin the LED is connected to we are controlling brightness so we use one of the PWM pulse width modulation pins void setup pinMode ledPi
43. this is going from 0 to 5 volts many times a second but in the human world we see it as a voltage For example if the Arduino is PWM ing at 50 we see the light dimmed 50 because our eyes are not quick enough to see it flashing on and off The same feature works with transistors Don t believe me Try it out More More More htt Transistor Getting Hot The transistor will get warm in most cases this is okay if you are worried about the temperature turn the circuit off for a bit and let it cool down More details where to buy more parts where to ask more questions tinyurl com d4wht7 void motorOnThenoffwithSpeed int onSpeed a number between 0 stopped and 255 full speed int onTime 2500 int of fspeed 50 a number between 0 stopped and 255 full speed int offTime 1000 analogwrite motorPin onSpeed turns the motor On delay onTime waits for onTime milliseconds analogwrite motorPin offSpeed turns the motor Off delay offTime waits for offTime milliseconds void motorAcceleration int delayTime 50 time between each speed step for int 1 0 1 lt 256 1 goes through each speed from 0 to 255 analogwrite motorPin 1 sets the new speed delay delayTime waits for delayTime milliseconds for int 71 255 1 gt 0 1 goes through each speed from 255 to 0 analogwrite motorPin 1 sets the new speed delay delayTime waits for delayTime
44. to type everything in just CIRC 03 Download the Code from http tinyurl com dagyrb then simply copy the text and paste it into an empty Arduino Sketch int motorPin 9 pin the motor is connected to void setup runs once pinMode motorPin OUTPUT loopQ run over and over again motorOnThenof Ff O motoronThenoffwithSpeed motorAcceleration motoronThenoff O turns motor on then off notice this code is identical to the code we used for the blinking LED void motoronThenoff int onTime 2500 on time int offTime 1000 off time digitalwrite motorPin HIGH turns the motor On delay onTime waits for onTime milliseconds digitalwrite motorPin LOw turns the motor Off delay offTime waits for offTime milliseconds Not Working 3 things to try Motor Not Spinning Different manufacturers produce the same transistor with different pin assignments Try turning the transistor 180 degrees Making it Better Controlling Speed We played with the Arduino s ability to control the brightness of an LED earlier now we will use the same feature to control the speed of our motor The arduino does this using something called Pulse Width Modulation PWM This relies on the Arduino s ability to operate really really fast Rather than directly controlling the voltage coming from the pin the Arduino will switch the pin on and off very quickly In the computer world
45. waits for a second Program Not Uploading Still No Success A broken circuit is no fun send us an e mail and we will get back to you as soon as we can help oomlout com Control the Brightness Along with digital on off control the Arduino can control some pins in an analog brightness fashion more details on this in later circuits To play around with it Change the LED to pin 9 also change the wire ledPin 13 gt int ledPin 9 Replace the loop code with analogwrite ledPin new number new number any number between 0 and 255 0 off 255 on in between different brightness Fading We will use another included example program To open go to File gt Sketchbook gt Examples gt Analog gt Fade Then upload to your board and watch as the LED fades in and then out 8 LED Fun Multiple LED s CIRC 02 What We re Doing We have caused one LED to blink now its time to up the stakes Lets connect eight We ll also have an opportunity to stretch the Arduino a bit by creating various lighting sequences This circuit is also a nice setup to experiment with writing your own programs and getting a feel for how the Arduino works Along with controlling the LEDs we start looking into a few simple programming methods to keep your programs small for loops used when you want to run a piece of code several times arrays used to make mana
46. with colored wires it is still shockingly easy to plug a servo in backwards This might be the case Making it Better Potentiometer Control We have yet to experiment with inputs but if you would like to read ahead there is an example program File gt Sketchbook gt Examples gt Library Servo gt Knob This uses a potentiometer CIRCO8 to control the servo You can find instructions online here http tinyurl com dymsk2 Self Timing While it is easy to control a servo using the Arduino s included library sometimes it is fun to figure out how to program something yourself Try it We re controlling the pulse directly so you could use this method to control servos on any of the Arduino s 20 available pins you need to highly optimize this code before doing that int servoPin 9 void setup pinMode servoPin OUTPUT More More More http More details where to buy more parts where to ask more questions tinyurl com djiwlo tell servo to go to position in variable pos waits 15ms for the servo to reach the position goes from 180 degrees to O degrees tell servo to go to position in variable pos waits 15ms for the servo to reach the position Sad Your Servo is Broken Still not Working Don t worry they are only a few dollars plus taking one apart is good fun you can try running the motor directly with a transistor Unfortunately some servos do break when plug
47. y an LED ge ARCI a EROS int ledPin 13 LED connected to digital pin 13 void setup run once when the sketch starts pinMode ledPin OUTPUT sets the digital pin as output loop run over and over again digitalwrite ledPin HIGH delay 1000 digitalwrite ledPin LOW delay 1000 Not Working 3 things to try LED Not Lighting Up LEDs will only work in one direction try taking it out and twisting it 180 degrees no need to worry installing it backwards does no permanent harm Making it Better Changing the pin The LED is connected to pin 13 but we can use any of the Arduino s pins To change it take the wire plugged into pin 13 and move it to a pin of your choice from 0 13 you can also use analog 0 5 analog 0 is 14 Then in the code change the line int ledPin 13 gt int ledPin newpin Then upload the sketch ctrl u Change the Blink Time Unhappy with one second on one second off In the code change the lines digitalwrite ledPin HIGH delay time on seconds digitalwrite ledPin LOW delay time off seconds 1000 1000 More More More http This happens sometimes the most likely cause is a confused serial port you can change this in tools gt serial port gt More details where to buy more parts where to ask more questions tinyurl com cmn5nh sets the LED on waits for a second sets the LED off
Download Pdf Manuals
Related Search
Related Contents
Audiovox CMOS2 User's Manual Manual - Skogma 取扱説明書 E (486KB) Eglo GLOSSY 1 Puma Eli Hunter 90064 Use and Care Manual User Manual - Chart Industries Cisco ASA 5505 Rack Mount Kit France-Paris: Travaux de démolition de bâtiments et travaux de Copyright © All rights reserved.
Failed to retrieve file