ThinkerShield For Arduino Quick-start Guide

2y ago
194 Views
12 Downloads
3.39 MB
64 Pages
Last View : 4d ago
Last Download : 3m ago
Upload by : Amalia Wilborn
Transcription

ThinkerShield for Arduino quick-start guide18 easy to followphysical computingactivities for theThinkerShield.Get on with it!Peter Mahony and James OliverGET.(ON).WITH.IT

GET.(ON).WITH.ITThinkerShield for Arduino quick-start guideMuseum of Applied Arts and Sciences

AcknowledgementsMaking and documenting something like the ThinkerShield requires input from lots ofclever people — probably too many to thank. We would however like to acknowledge somekey individuals who made major contributions to the project: John Hirsch, Arturro Rivillo,Robbie Mudrazija, Joy Suliman, Samuel Bruce, Mark Scarcella, Curtis Black, Lucy McGinley,Fil Bartkoviak and Craig Browne. Thank you guys!Thanks also to the countless young enthusiastic participants who helped us test the product inour MAAS Digital Learning workshops.We would also like to acknowledge the creative electronics expertise and support provided bythe team over at Freetronics: Jonathan Oxer, Marc Alexander and Angus Gratton.While care has been taken in the preparation of this book, the MAAS and the authors assume no liability forerrors or omissions, or for damages or loss resulting from the use of the information contained in its contents.In addition, no responsibility is taken for any information or services which may appear on any linked websites.You may reproduce this document for your personal and educational use. You may also reproduce and shareyour projects and code that include information contained in this book provided that you acknowledge thisbook as the source. You may not however imply that the MAAS endorses you or your use of the material withoutexpressed written permission.The Museum of Applied Arts and Sciences is an executive agency of the NSW Government. 2015-2016 Copyright Museum of Applied Arts and Sciences. ‘Arduino’ is a brand of Arduino LLC.

ContentsIntroduction . . . . . . . . . . . . 5Push.Button.Basics. . . . . . . . . 30Get.Connected. . . . . . . . . . 6Get.A.Toggle.On. . . . . . . . . . 32What’s.On.Board?. . . . . . . . . 9Buzzer.Basics. . . . . . . . . . . 34In.A.Blink . . . . . . . . . . . . . 10Pitch.Changer. . . . . . . . . . . 36What’s in an Arduino program?. . . . 12Play.A.Song . . . . . . . . . . . . 38Getting.Flashy . . . . . . . . . . . 14Electronic.Dice . . . . . . . . . . 40Even.Flashier. . . . . . . . . . . 16Buzzing.Light.Meter. . . . . . . . 44Pot.Basics. . . . . . . . . . . . . 18LED.Magic.Sign. . . . . . . . . . 48A.Light.Dimmer. . . . . . . . . . 20Connect.A.LED. . . . . . . . . . 52Decode the light dimmer code. . . . 22Traffic.Lights. . . . . . . . . . . 54POT.LED.Bouncer. . . . . . . . . 24Digital.Spoon.Piano . . . . . . . . 56LDR.Basics. . . . . . . . . . . . 26What.Next?. . . . . . . . . . . . 60LDR.Night.Light . . . . . . . . . . 28

All you need:*GND VCCD6D5GreenLEDsButtonD7D8D9D10D11D12D13GND VCCD4D2BuzzerLDRA4ResetPOT A5A0A1A2A3ThinkerShieldboardA quick-start board madeup of a unique blend ofon-board componentsto make it easy to startdoing computer controlledactivities. It can also beexpanded using standardArduino compatiblecomponents.4Personalcomputerrunning ArduinosoftwareArduino software is free todownload and use from:www.arduino.ccArduino boardUSB cableSuch as:To connect your Arduinoboard to your computer.This provides power to theboard and allows programupload. Arduino Uno Freetronics Eleven Genuino Uno or any Arduinocompatible board thathas a standard ArduinoUNO header layout.*Well, almost! You will need a few other components for the Let’s.Get.Beyond.It projects:3 LEDs (red, green, yellow) , 3 resistors (220 ohm) and 9 wires with alligator clips.Get’em from any electronics shop for just a few dollars.

ongnd too l t grabepst’nsDopage. Juon this inkerShield andyour Th and let’sArduino ith it!get on wIntroductionThe ThinkerShield for Arduino is a learn-by-making product from The Labat the Museum of Applied Arts and Sciences in Sydney, Australia.At The Lab we love learning-by-making. We think everybody should be ableto dive in and just start playing and learning right away.The Arduino board and programming language is a worldwidephenomenon bringing the exciting world of electronics and computercontrol to anyone with a computer and a USB cable.So, together with the clever folks at Freetronics, we created theThinkerShield for Arduino. The ThinkerShield makes it easy for you, yourfamily, your schoolmates and friends to start programming and controllingthings with your computer in minutes! No need for any wiring or solderingor program knowledge.Even if you have never seen a computer program before, we guaranteeyou will be making things flash, buzz, beep and respond in no time.Then, when you are ready to move on to bigger things, the ThinkerShieldhas 8 built‑in external connectors that make it easy for you to connect allmanner of devices like switches, lights, motors and sensors.So, don’t just watch what’s going on in the world of electronicsand computing. Take a step to start understanding it. Grab yourThinkerShield and get.on.with.it!5

Get.Connected1. Install ArduinoInstalling the Arduino software foryour computer is usually prettystraightforward.Just go to the Arduino website andfollow the links to the downloadspage. Select the latest version foryour computer (Windows, Macor Linux).www.arduino.ccThe site covers everything youneed to get up and running and totroubleshoot any problems youmay have.2. Install driversDepending on your computer andoperating system, you may needto install a driver for your Arduinoboard. Again, the best advice we cangive you is to follow the steps setout on the Arduino site. Just search‘install drivers’ or go straight to:3. Connect yourThinkerShield to yourArduino and computerCarefully align all yourThinkerShield’s leg pins with thesockets on your Arduino andpress them together.www.arduino.cc/en/Guide/HowtoOf course, if you are using anArduino compatible boardyou should install the driversrecommended by the board’smanufacturer.Make sure everything isaligned, otherwise you maybend the pins or the sockets.6

4. Select the boardand serial portConnect your Arduinoto your computer usingthe appropriate USBconnector such as a USBB-Type cable or microUSB cable (as per yourboard manufacturer’sspecifications).If yourThinkerShield isgetting powerfrom theArduino, thisblue LED willstay on.Once your board is connected, both theserial port and board selections can bemade from the Arduino ‘Tools’ menu.The Arduino softwareneeds to know whichcommunication port isbeing used and what typeof Arduino board you have.The board type will bestated in the manufacturer’s specifications (such asArduino UNO).The serial port on Windows will likelybe COM3, COM4 or COM5. On aMac it will be something like:/dev/cu.usbserial-1B1.If you can’t easily see which port isbeing used, try: using system profiler (on Mac) ordevice manager from the controlpanel (on Windows) to identifywhich port the board is using look at the list of available serial ports (in theTools menu), then unplug your board and re‑openthe menu. The entry from the list that disappearsis the correct serial port for your board checking troubleshooting on the Arduino site.7

What is Arduino?5. DownloadThinkerShieldprogram code filesAll activities in this book haveassociated program code for you toload and complete.Before you start your Arduinosoftware, download all the programcode files from our site:maas.museum/learn/thinkershield/Copy the files to a convenientlocation on your computer. Thecode files are divided into twofolders: activity and completed. Thefiles in the activity folder are forworking through the activities. Thecompleted versions are ready to beuploaded and run at any time.6. Launch!Launch the Arduino application(arduino.exe) you have previouslydownloaded.When it opens:1/go to File/Open.2/navigate your way to yourThinkerShield folder you justdownloaded3/open the folder calledts In A Blink4/ double-click on the filets In A Blink.ino5/Get on with it![Turn to the first activity]Arduino is an open-source electronicsprototyping platform based onflexible, easy-to-use hardware andsoftware. It’s intended for artists,designers, hobbyists and anyoneinterested in creating interactiveobjects or environments.Arduino can sense the environmentby receiving input from a varietyof sensors and can affect itssurroundings by controlling lights,motors and other actuators.The microcontroller on the boardis programmed using the Arduinoprogramming language (based onWiring) and the Arduino developmentenvironment (based on Processing).Arduino projects can be stand‑aloneor they can communicate withsoftware running on a computer(eg Flash, Processing, MaxMSP).www.arduino.ccsource: Arduino site8

What’s.On.Board?Vcc ( 5 volts)push buttona simplemomentaryswitchGND (0 volts)detachable buzzer jumperpull it off to silence thebuzzerUSB port(on Arduino board)to connect to yourcomputerpiezo buzzerfor making soundand musicpotentiometera controllablevariable resistor6 green light-emittingdiodes (LEDs)for making lightexternal power socket(on Arduino board)to power board when notconnected to a computerexternal digital pin connections(D6, D5, D4, D2)for connecting additionalcomponents ( 5 volts)light dependent resistorfor sensing lightreset buttonpress to reset andrerun the currentlyloaded programexternal analog pin connections(A0, A1, A2, A3)for connecting additionalsensors ( 5 volts)9

Component: LEDsWe think the best way to make sure your ThinkerShield isconnected correctly and everything is working properly is to makeit do something — straight away! So let’s make one of those cutelittle LEDs blink!In.A.BlinkStart by flashing a LEDGND ND VCCD8D9D10D11D12D13D4D2BuzzerConnect yourto yourThinkerShielden to yourthdArduino anthe USBcomputer withcable.LDRA4ResetPOT A5A0A1A2A3Open a very simpleArduino program that willmake the LED on pin D13flash on and off.LED on pin D13Ingredients10Upload theprogram to yourThinkerShield.Check thateverythingworks and startexperimentingin a blink!The wordsshould ap ‘Compiling sketch’pear momthe statues bar as ntarily inthe greenupload baworks, yo r updates. If everuy‘Done up will see the mess thingloading’ageand thewill flashD13 LEDtwicetohas finishleed upload t you know iting.

LET’S.GET.(ON).WITH.IT1/ Set up and connect your ThinkerShield and Arduinosoftware as shown in the previous pages.2/ Open the filets LED In A Blink.ino3/ Upload your program by clicking on the4/ The LED on pin D13should begin to flashslowly on and off onceevery second. If it does,everything is workingfine (yippee! — moveon to step 5). If notcheck everything in the‘Not working?’ columnuntil you solve theproblem.5/ Try this:Look at the programcode on your screenand find this section.Try changing thedelay(1000) toanother number suchas delay(500)andclick upload to makethe LED flash at adifferent rate!icon.Not working? Is the Arduino getting power? If itis connected correctly you shouldsee a tiny green LED next to theword ON. If not, check your USBconnection. Is your ThinkerShield connectedcorrectly to your Arduino board?Make sure all legs are nicely alignedand embedded in the black sockets./* This is the COMPLETE prom for the ThinkerShield In AWritten by Thinkspace wwwgraBlink Activity.maas.museum/thinkspaceThis code is based on the public-domain code created by www*/.arduino.cc// Your ThinkerShield has anLED connected// to Pin 13 (as have most Arduino boards).// Give the pin a name: led int led 13;// The setup routine runs once when you press reset:void setup() {// Initialize the digital pin asan output.pinMode(led, OUTPUT);}// The loop routine runs over and over again forever:void loop() {digitalWrite(led, HIGH); // Turn the LED on (HIGH is the voltdelay(1000);age level)t for a seconddigitalWrite(led, LOW); //// WaiTurn the LED off by makingdelay(1000);the voltage LOW// Wait for a second} Have you selected the correct boardtype from the ‘Tools Board’ menuon your Arduino software? Have you selected a serial port fromthe ‘Tools Serial Port’ menu onyour Arduino software? Is the program uploadingsuccessfully? Do you see themessage ‘Done uploading’?Still not working? Shutdown the Arduino program onyour computer and unplug the USBfrom your computer and go throughsteps 1 to 3 again. Go to: www.arduino.cc click onForum and look for troubleshooting.11

Comments: appear in grey. They are explanatorynotes used to tell yourself (and other programmers)what the next bit of code is supposed to do or whereit is from. Single line comments begin with //.Blocks of comments are enclosed between /* */the ThinkerShield In A Blink Activity/* This is the COMPLETE program forum/thinkspace.musemaaswww.spaceThinkWritten bycreated by www.arduino.ccThis code is based on the public-domain code*/ected// Your ThinkerShield has an LED conn// to Pin 13 (as have most Arduino boards).// Give the pin a name: led int led 13;press reset:// The setup routine runs once when you{()setupvoid// Initialize the digital pin as an output.pinMode(led, OUTPUT);}forever:// The loop routine runs over and over againvoid loop() {on (HIGH is the voltage level)digitalWrite(led, HIGH); // Turn the aLEDdseconforWait//delay(1000);off by making the voltage LOWdigitalWrite(led, LOW); // Turn thea LED// Wait for seconddelay(1000);}keyWords: These words have particular meaning in theArduino language. They always appear in orange.void setup ( ) {.} This runsonce after the program is uploadedand run — you will always use thisto setup pinModes.void loop ( ) {.} This section ofthe program runs continuously afterthe setup( ) function has run.Semicolon: Each line of codeends with a ;{ } Curly braces: Your codemust be enclosed betweencurly braces.Constants:Are predefinedexpressions in theArduino language(like HIGH, LOW,INPUT, OUTPUT,true, false). Theywill appear in blueor orange.Debugger area:Any errors will bedisplayed here.Status bar: Displays the current board typeand which COM port is being used.12

What’s in an Arduino program?There are zillions of Arduino based programs all over theweb that you can download, try out and try to understand.And you can be pretty sure that they will all have the basicelements and structure shown here on these pages.Aris fr duinoyou ee an softwadrmic to prog allows erroam‑cyIt dour Thi ontroll thebet oesn’t nkerS er onhtertha get ea ield.n th sierat! orSketch: Arduino people like tocall their programs ‘Sketches’.Upload program: Click this iconto transfer your program to theThinkerShield. This little arrow willquickly become your favourite button!Verify program:Check your program for errors beforeuploading. You probably won’t needto verify before uploading programsin this book, but it might help as youcreate larger programs.Serial monitor:Open the serial monitorfor watching serialcommunication.Need help, or just wantto start exploring onyour own?Whatever your question, chances arethe answer is waiting for you on theofficial Arduino website. It’s easy tofollow and filled with solutions, forumsand ideas for everything Arduino!www.arduino.cc13

Component: LEDsNow let’s start talking to your ThinkerShield and take controlof those LEDs so you can make any of them flash how youwant them to!Getting.FlashyControlling a LEDGND ND VCCD8D9D10D11D12D13D4D2BuzzerLDRA4te aWe first creawe canatvariable the numberthldhouse ton of thepiof the digitalcontrol.totanLED we wpin 12.We’ll start withWait onesecond.ResetPOT A5A0A1A2The waiting time isentered as milliseconds(thousandths of asecond). So delay(1000)tells the program towait one second.Wait onesecond.A3Light-emittingdiode (LED) ondigital pin D12Then we use a functioncalled pinMode( ) to setthe pin as an OUTPUT.Otherwise it will defaultto an input.Ingredients14Next we do what’scalled a digitalWrite tothe ledPin and send itHIGH to turn it on.Do anotherdigitalWrite to theledPin and send itLOW to turn it off.Loop aroundforever.

LET’S.GET.(ON).WITH.IT1/ Open the filets LED Getting Flashy.ino2/ Look for the comment // Setup LED variables// Setup LED variables.// The setup routine runs once when you press reset:void setup()and insert the following line of code:int ledPin 12;This creates avariable called‘ledPin’ that we canuse to refer to theLED on pin 12.I know this ismuch the sam prettyactivity, but e as the firsthow to write now you knowthinitialise a d e code toset it as an ouigital pin andpinMode. Try tput usingledPin numb changing theer!3/ Find the comment // Set the LED pin as an output// Setup the LED pin as an output.}and insert the following line of code:pinMode(ledPin, OUTPUT);This gets the LEDon pin 12 ready forflashing.4/ Look for the comment // Turn the LED on and off{// Turn the LED on and off.}and add the following 4 lines of code:digitalWrite(ledPin, HIGH); // LED ondelay(1000); // Wait 1 secdigitalWrite(ledPin, LOW); // LED offdelay(1000); // Wait 1 secTurn the LED onby setting the voltageHIGH. Wait, then set thevoltage LOW (and the LEDgoes off).5/ Upload your program. The LED on pin 12 shouldflash on and off each second.15

Component: LEDsEven.FlashierControlling multiple LEDsat the same timeGND ND VCCD8D9D10D11D12D13D4D2BuzzerYour ThinkerShield has six LEDs (on digital pins D8-D13). With somesimple changes to your program code you can easily control them— one at a time, all at once or in patterns and sequences.Let’s start with two of them!es for eachSet up variablns forpiltaof the digis you willDLEethofeachchoseebe flashing. W.13pins 8 andLDRA4ResetPOT A5A0A1A2A3void setup()Then, in voidsetup( ), usepinMode to seteach LED pin as anOUTPUT.Light-emittingdiodes (LEDs) ondigital pins D8and D13Ingredients16void loop()Next, in void loop( ),do various patterns ofdigitalWrites to send eachLED high or low accordingthe on/off pattern youwant to create.Get flashier andflashier andflashier!

PICK A PATHLET’S.GET.(ON).WITH.IT1/ Open the filets LED Even Flashier.inoPage 48Make a LEDmagic sign2/ Look for the comment // Setup LED variables// Setup LED variablesint led1Pin 13;and insert the following code:int led2Pin 8;3/ Find the comment // Set LED pins as digital outputsThis will define oursecond LED pin.Next PageLearn to use thepotentiometer// Set LED pins as digital outputspinMode(led1Pin, OUTPUT);}and insert the following code:pinMode(led2Pin, OUTPUT);4/ Look for the comment // Turn the LEDs on and off// Turn the LEDs on and off}and add the following delay(500);HIGH); // LED1 onLOW); // LED2 offLOW); // LED1 offHIGH); // LED2 onOur second LED isnow ready for use asan output.Turn LED1 onand LED2 off(it won’t matter ifit’s already off).Do the opposite.I added athird LED to myprogram. Then Ire-arranged thecode so thatall the LEDswere blinkingtogether andwith differentpatterns anddifferentdelays!5/ Upload your program. The LEDs on pins D13 and D8should flash on and off every half second.17

Component: potentiometerPot.BasicsReading the potentiometerGND VCCD6D5GreenLEDsButtonD7D8D9D10D11D12D13GND VCCD2bleCreate a variaethto holdpotPin value.BuzzerSend the value tothe serial monitor.A potentiometer is ananalog device so weuse the analogRead( )function to get avalue from it.LDRA4ResetPOT A5A0Potentiometeron analogpin A518D4Learn to read the ThinkerShield’s potentiometer (a variable resistor)and how to print the values to the serial monitor so you can seethem on your computer screen.A1A2POT A5A3Turn on theserial port withSerial.begin sowe can see thevalues from thepotentiometer onanalog pin A5.Ingredientseevices likAnalog dmeters (orpotentio re often used‘pots’) a s on lights.as faderThen find outhow the valueschange asyou turn thepotentiometerback and forth.

See also:cereal monsterLET’S.GET.(ON).WITH.IT1/ Open the filets Pot Basics.ino2/ Find the comment // Define potentiometer pin// Define potentiometer pinand insert the following code:int potPin A5;3/ Find the comment // Turn the serial port on{// Turn the serial port on.}and insert the following code:Serial.begin(115200);4/ Locate the comment // Read the input pin// Read the input pinand insert the following code:potValue analogRead(potPin);Create a variablefor analog pot pin A5.Activate the serial monitor soyou can use it to see values onyour computer screen.This will put the value ofthe potentiometer into avariable called ‘potValue’.It will return valuesbetween 0 and 1023.5/ Lastly, find the comment // Print the contents of .// Print the contents of the variable to the serial monitor.// Short delay before reading again.and insert this line of code:Serial.println(potValue);The serialmonitor letsyou see thevalues comingfrom yourcomponents.This line prints thevalue to the serialmonitor so you can seeit. Once the programis running, click thisicon!6/ Upload your program and open the serial monitor.Turn the pot back and forth and see how the values change!baud rateNot working? Check your code for missing; or ( ) or . or { } Make sure potPin 5 (notsome other number). Do the baud rates in thecode and on the serialmonitor match?19

Component: potentiometerA.Light.DimmerMake a light dimmer controlGND ND VCCD2LDRA4singby initialiWe starts thatinpDEeLone of th techniqueasupportsM. OnWcalled Pse arehield theThinkerShisTand 11.pins 9, 10 ght.ur liwill be oDo an analogWrite( ) tothe LED pin. This givesus more control thanjust a digitalWrite( )which can only switchbetween high and low.ResetPOT A5A0D8D9D10D11D12D13Light-emittingdiode (LED) ondigital pin D920D4BuzzerNow that we know how to read the values from the potentiometerwe can use it to control the brightness of the ThinkerShield’s LEDs— just like a light dimmer.A1A2A3Then we insert a line ofcode that uses the map( )function to convert valuescoming from the (analog)potentiometer so we can sendthem to the (digital) LED.POT A5Potentiometeron analogpin A5IngredientsExperiment with differentpotentiometer positions tosee the effect on the LEDbrightness and create someromantic mood lighting!

LET’S.GET.(ON).WITH.IT1/ Open the filets Pot Light Dimmer.ino2/ Look for the comment // Define pins// Define pins.int potPin A5;and insert the following code:int ledPin 9;3/This creates avariable for digitalLED pin D9.This willLook for the comment // Map the function asconvert ourPWM supports 0 to 255 not 0 to 1023potentiometer// Map the function as PWM supports 0 to 255 not 0 to 1023. values, whichhave a range of// Write the value to the LED.0-1023 to PWMand insert the following:friendly valuesvalue map(value, 0, 1023, 0, 255);in the range of0-255.4/ Find the comment // Write the value to the LED// Write the value to the LED.// Short delay before reading again.and insert the following code:analogWrite(ledPin, value);This will sendour value to ourselected LED pin.PICK A PATH5/ Upload your program.6/ Try turning the potentiometer. You should seethe brightness of the LED change in response.The light dimmer is using somethingcalled Pulse Width Modulation (orPWM) to send varyingamounts ofpower to the LED — which changesit’s brightness. PWM works byswitching the power onand off veryfast. The longer it is oncompared tooff, the higher the amount of powersupplied (and the brighter your LED!)On the ThinkerShieldyou can doPWM on digital pins 3,5, 6, 9, 10, 11.And we have alreadyhave a LED on9, 10 and 11.Be careful it doesn’tget too romantic! Page 26Jumpstraightto the LDRNext PageGimmemorePOT stuff21

Let’s decode the Light Dimmer Code/* This is the COMPLETE programfor the ThinkerShield Pot Light Dimmer ActivityWritten by Thinkspace www.maas.museum/thinkspace*/pin 5// ThinkerShield has a potentiometer connected to analog// Pins that support PWM are 3,5,6,9,10,11. We already have LEDs// permanently connected to pins 9,10,11.// Define pins.int potPin A5;int ledPin 9;// Create a variable to hold the data we read in.int value 0;void setup(){// Turn the serial port on.Serial.begin(115200);// Initialize the LED pin as a digital output.pinMode(ledPin, OUTPUT);}22continued on opposite pageint ledPin 9;Declares a variable called‘ledPin’ and assigns it thevalue ‘9’ which correspondsto the number of the pinthat our LED is connectedto. We did a similar thingfor the potPin but weused A5 so we know we arereferring to an analog pin.void setup( ){.}Set up the serial portand the baud rate sowe can send data tothe serial monitor.By default all pins are setas INPUT. So, we need toset the pinMode for theledPin as OUTPUT. ThepotPin will default toinput as we need it to be.In programis a value t ming, a variabledepending hat can change,oon informa n conditions ortto the prog ion passeduse variableram. You willin your cod s all the timeeasier to doe to make itthings.

Everything between the { } after thevoid loop( ) function runs repeatedlyuntil the program is stopped.continued.value analogRead(potPin);This is a very common commandused to read the current value onan analog pin and store it in thevariable called ‘value’.void loop(){// Read the input pin.value analogRead(potPin);// Print the contents of the variable to the serial monitor.Serial.println(value);// Map the function as PWM supports 0 to 255 not 0 to 1023.value map(value, 0, 1023, 0, 255);// Write the value to the LED.analogWrite(ledPin, value);}// Short delay before reading again.delay(25);delay(25);This literally means do nothingfor 25 milliseconds. It stops usgetting zillions of readings.value map(value, 0, 1023, 0, 255);The map function makes it easy to scale, ormap, one range of values to another range. Inthis case, it converts from the potentiometer’svalues that range from a lowest value of 0 andhighest value of 1023 to a range from a lowestof 0 to a highest of 255. So, if the value fromthe pot was 1023 it will be mapped to 255. Ifit was say 512 (half-way between 0 and 1023)it will be mapped to a value of 127 (half-waybetween 0 and 255).analogWrite(ledPin, value);The opposite of an analogRead, thiswrites a value to the analog pin.Because this pin supports PWM itmeans that we can send differentamounts of power to the LED.23

Component: potentiometerPOT.LED.BouncerUsing analog values to switchLEDs on and offGND sGND VCCBuzzerisingStart by initialasnstwo LED pickedpieWs.output.13Ddan8DpinsLDRA4ResetPOT A5A0D8D9D10D11D12D13Light-emittingdiodes (LEDs)on digital pinsD8 and D1324D2With just a little bit of extra code you can turn the potentiometerinto a switch-type control and use it to bounce between two of theThinkerShield’s LEDs.A1A2Now, test the valueto see if it is either1023 or 0. Thesevalues tell us thatthe pot is turned allthe way to the leftor all the way tothe right.A3POT A5Potentiometeron analogpin A5Read the valuecoming fromthe pot on pinA5 and storethe value in avariable.IngredientsWait a momentand looparound again.If it is one of these values weuse digitalWrite( ) to change thestate of the two LEDs . the onethat’s on gets turned off and theone that’s off gets turned on.So, whenknob all tyou turn theone side t he way fromthe LEDs o the other,and forth bounce back!

LET’S.GET.(ON).WITH.IT1/ Open the filets Pot LED Bouncer.ino2/ In the void setup section, find the comment // Initialise theLED pins as digital outputs// Initialise the LED pins as digital outputs.6/ Try turning the potentiometerfrom left to right and see if theLEDs bounce back and forth.// Turn the serial port on.and insert these two lines of code:pinMode(led1Pin, OUTPUT);pinMode(led2Pin, OUTPUT);Set the LED pinsas OUTPUTS3/ Find the comment // Read the input pin// Read the input pin.// Print the contents of the variable to the serial monitor.and insert the following code underneath:value analogRead(potPin);4/ Find the comment // Use if statement toturn LEDs on and off// Use if statement to turn LEDs on and off.// Short delay before reading again.and insert these ten lines of code:5/ Upload your program.Use analogRead()to get the currentvalue from thepot and store itin ‘value’.7/ If you turn on the serial monitoryou will be able to see the valuesas they change!Test to see if the value equals 1023.If it does, do the first bit (led1 on,led2 off). If not, test to see if itequals zero. If it does, it does thesecond bit. If it doesn’t equal either1023 or 0 don’t change anything.if(value lse if(value 0){digitalWrite(led1Pin,digitalWrite(led2Pin,} means ‘is equal to’HIGH);LOW);LOW);HIGH);25

Component: LDRLDR.BasicsRead the LDR to sense lightGND VCCD6D5GreenLEDsButtonD7D8D9D10D11D12D13GND VCCD2Buzzerrial portTurn on the sein soegl.briawith Sevaluesethesencawe.ornsfrom the seSend the valueto the serialport.LDRA4ResetPOT A5A0Lightdependentresistor (LDR)on analogpin A426D4Learn to read the values of the ThinkerShield’s light sensor(called a light dependent resistor) and see how it responds todifferent light conditions.A1A2A3The LDR is an analogdevice so we use theanalogRead( ) functionto get a value from it.LDRA4IngredientsThen have some funtesting with differentamounts of light onthe sensor.

PICK A PATHLET’S.GET.(ON).WITH.IT1/ Open the filets LDR Basics.ino2/ Find the comment // Turn the serial port on// Turn the serial port on.}Page 36Use the POTto control thebuzzerThis will activate theserial monitor so youcan use it to readvalues.and insert the following code:Serial.

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

Related Documents:

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 .

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?

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

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

Albert Woodfox were properly convicted for the 1972 murder of prison guard Brent Miller. Supporters of Wallace and Woodfox, who make up two-thirds of a group known to supporters as the "Angola Three," say that the convictions were at least partly because of the men's involvement with the Black Panther Party. "Under this new governor's office, this new day, we are making sure we right the .