Arduino Comic Latest3

Embed Size (px)

Citation preview

  • 8/4/2019 Arduino Comic Latest3

    1/15

    resources that can be used, redistributed or rewritten free of charge.often software or hardware.

    technology which makes use of the controlled motion of electronsthrough different media.

    an original Form that can serve as a basis or standard for other things.

    hardware architecture with software framework on which other softwareCan run.

    what is an

    arduino?

    electronics prototyping

    platform.

    what does that mean?

  • 8/4/2019 Arduino Comic Latest3

    2/15

  • 8/4/2019 Arduino Comic Latest3

    3/15

  • 8/4/2019 Arduino Comic Latest3

    4/15

  • 8/4/2019 Arduino Comic Latest3

    5/15

  • 8/4/2019 Arduino Comic Latest3

    6/15

    http://arduino.cc/en/Main/Software
  • 8/4/2019 Arduino Comic Latest3

    7/15

    Next select the serial port.

    (Tools > serial port) On a mac it will be

    something like/dev/tty.usbmodem. On awindows machine, it will becom3or somethinglike that.

    Launch the arduino software. in the tools menu,select the board you are using (tools > board).for example, Arduino Uno.

    When you have installed the software,

    Connect the arduino. An led markedONshould light up on the board.

    for instructions on how to installarduino software on a mac:

    http://www.arduino.cc/en/Guide/MacOSX

    For Instructions on how to install

    on Windows:

    http://www.arduino.cc/en/Guide/Windows

    For Instructions on how to installon Linux:

    http://www.arduino.cc/playground/Learning/Linux

    go to the URLS above for detailed instructions oninstalling the software on these platforms.

    http://www.arduino.cc/en/Guide/MacOSXhttp://www.arduino.cc/en/Guide/Windowshttp://www.arduino.cc/playground/Learning/Linuxhttp://www.arduino.cc/playground/Learning/Linuxhttp://www.arduino.cc/en/Guide/Windowshttp://www.arduino.cc/en/Guide/MacOSX
  • 8/4/2019 Arduino Comic Latest3

    8/15

    the led at pin 13 on the arduino starts blinking.

    To upload the sketch to the arduino board,

    click theupload buttonon the strip of

    buttons at the top of the window. somemessages will appear in the bottom of the

    window, finallyDone Uploading.

    Upload button

    The Arduino IDE allows you to writeSketches, orprograms

    and upload them to the Arduino board. open theblinkexamplein the file menu. File > Examples > 1.Basics > Blink.

    When you downloaded theArduino software, you

    downloaded anIDE. it combinesa text editor with a compiler

    and other features to helpprogrammers develop software.

    whats an

    IntegratedDevelopmentenvironment?

  • 8/4/2019 Arduino Comic Latest3

    9/15

    void setup() {

    pinMode(13, OUTPUT);

    }

    void loop() {

    digitalWrite(13, HIGH);

    delay(1000);

    digitalWrite(13, LOW);

    delay(1000);

    }

    //DeClares block of code

    //declares block of code

    //sets pin 13 to output

    //sets pin 13 low

    //sets pin 13 high

    //pause 1 second

    //pause 1 second

    //End block of code

    //End block of code

    For now, lets look at this simple script lineby line & see what each line does.

    http://arduino.cc/en/Reference/HomePage

    check out the arduino website for thearduino reference guide and many otherresources to learn the language.

    setup: happens one time whenprogram starts to run

    Loop: repeats over andover again

    These Are both blocks of code called

    functionsthat every sketch will have. Theyare blocked out by curly Braces { }.

    void setup() {// initialize the digital pin as an output.// Pin 13 has LED connected on most Arduino boards:

    pinMode(13, OUTPUT);}

    void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second}

    a sketch, like a program writen in anylanguage, is a Set of instructions for thecomputer. If we look closely at the Blink

    sketch, we see there are 2 major parts,setupandloop.

    http://arduino.cc/en/Reference/HomePagehttp://arduino.cc/en/Reference/HomePage
  • 8/4/2019 Arduino Comic Latest3

    10/15

  • 8/4/2019 Arduino Comic Latest3

    11/15

    the led blinks on for half a second, thenblinks off for half a second, over and over

    again.

    click verify on the menu to check your code. ifthere arent any errors, click upload to putyour program on the arduino.

    upload button

    verifybutton

    void setup() {pinMode(2, OUTPUT);

    }

    void loop() { digitalWrite(2, HIGH);

    delay(500);digitalWrite(2, LOW);delay(500);

    }

    in setup, we set pin 2 to be anoutput. in loop, first we set pin 2high which lights the led. Delaypauses 500 milliseconds, or half a

    second. when pin 2 is set low, theled goes off, we pause another halfsecond.

    theanodeis connected topin 2on the arduino througha220 ohm resistor. Thecathodeis connected toground. pins 2 through 13 can be configured as digitalinputs or outputs. clickNewbutton to start a sketch.

  • 8/4/2019 Arduino Comic Latest3

    12/15

    The LED lights when the switch is held down.

    void setup() {pinMode(2, OUTPUT);pinMode(4, INPUT);

    }

    void loop() { if(digitalRead(4)){ digitalWrite(2, HIGH);}else{digitalWrite(2, LOW);}

    }

    Next well write the code. In setup, we declarepin 2 an output and pin 4 an input. in loop, we

    use an if statement, if we read pin 4 as high, weset the led pin to high, otherwise we set theled pin to low, turning it off.

    Connect one end of a momentary switch to pin 4 on theArduino, with a 10k resistor connected to ground

    attached to the same end. Attach the other end topower. We will leave the LED attached to the same pin.

    Next we will add a switch, a digitalinput, so we can turn the LED off

    and on.

  • 8/4/2019 Arduino Comic Latest3

    13/15

    Serial Monitor

    click to open

    serial window

    after you have uploaded the script to thearduino, click theSerial Monitorbutton in

    order to see the values as you turn the pot.A window will open, and you will see valuesranging from 0 to 1024 as the pot is turned.

    void setup() {Serial.begin(9600);

    }

    void loop() { Serial.println(analogRead(A0));}

    First we will look at the range of values weget by turning the pot using theSerial

    monitor. in our code, we initialize the serialobject in setup, setting a baud rate of 9600.

    In loop, We read the value from analog pin a0and print it to the serial object using theprintLnfunction,

    Attach the middle pin on the potentiometer to Analog pinA0. attach one end of the pot to power, the other toground.

    Now we will set up an analog input.Well use a potentiometer.

    apotentiometer, orpot, is avariable resistor. the amountof resistance changes as it

    is turned, increasing ordecreasing depending on

    which direction it isturned.

  • 8/4/2019 Arduino Comic Latest3

    14/15

    The brightness of the LED changes, rangingfrom completely off to very bright as youturn the pot.

    int sensorValue = 0;

    void setup() {pinMode(3,OUTPUT);

    }

    void loop() {sensorValue = analogRead(A0);analogWrite(3,sensorValue/4);

    }

    First we create avariableto store the valueof the pot. In setup we make pin 3 an output.In loop, we store the value we have read frompin a0 in our variable. Then we write the valueto pin 3, our led pin. we have to divide thevariable by 4, so we will have a range of valuesfrom 0 to 255, or abyte.

    100% Duty Cycle - analogWrite(255)

    5V

    0V

    50% Duty Cycle - analogWrite(127)

    5V

    0V

    0% Duty Cycle - analogWrite(0)5V

    0V

    Well usepulse width modulation(PWM). This is a method of simulatingan analog value by manipulating thevoltage, turning it on and off at

    different rates, orduty cycles

    . youcan use pwm with pins 3, 5, 6, 9, 10,and 11.

    Lets use the changing values we receive from the potas a dimmer to light an LED. put the led back into theboard, attached to the Arduino at pin 3.

  • 8/4/2019 Arduino Comic Latest3

    15/15

    all text and drawings byJody Culkinfor more, check outjodyculkin.com

    Special Thanks to Tom Igoe, Marianne petit, CalvinReid, The faculty and staff of theinteractive

    telecommunications program at nyu, particularlyDan osullivan, Danny rozin and Red burns. thanksto Cindy karasek, chris Stein, sarah teitler, kathygoncharov & zannah marsh.

    many, many thanks to theArduino team for bringingus this robust and flexible open source platform.

    and thanks to the lively, active and ever growingarduino community.

    Introduction to Arduino by Jody Culkinis licensed under a Creative CommonsUnported License.

    books

    Tutorials

    Arduino site Tutorialshttp://www.arduino.cc/en/Tutorial/HomePage

    Lady Adahttp://www.ladyada.net/learn/arduino/

    Instructables

    Getting Started with Arduino by Massimo Banzi

    Arduino to see, hear, and feel your world byTom Igoe

    Physical Computing: Sensing and Controlling

    the Physical World with Computers by DanO'Sullivan & Tom IgoeArduino Cookbook by Michael Margolis

    Links

    Supplies

    Software

    Software Downloadhttp://www.arduino.cc/en/Main/Software

    Language Reference

    http://arduino.cc/en/Reference/HomePage

    Sparkfun Electronicshttp://www.sparkfun.com/

    Adafruit Industrieshttp://adafruit.com/

    Maker Shedhttp://www.makershed.com/

    Jameco Electronics

    http://www.jameco.com/

    Thats it!This is a very briefintro. in the nextPanels, there arelinks and other

    resources. checkthem all out,

    youll find more!

    http://www.jodyculkin.com/http://itp.nyu.edu/itp/http://itp.nyu.edu/itp/http://www.arduino.cc/en/Main/Creditshttp://arduino.cc/forum/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://creativecommons.org/licenses/by-nc-sa/3.0/http://www.arduino.cc/en/Tutorial/HomePagehttp://www.ladyada.net/learn/arduino/http://www.instructables.com/tag/type-id/category-technology/channel-arduino/http://www.instructables.com/tag/type-id/category-technology/channel-arduino/http://oreilly.com/catalog/9780596155520http://oreilly.com/catalog/0636920010920http://oreilly.com/catalog/0636920010920http://oreilly.com/catalog/0636920010920http://edu.cengage.co.uk/catalogue/product.aspx?isbn=159200346Xhttp://edu.cengage.co.uk/catalogue/product.aspx?isbn=159200346Xhttp://edu.cengage.co.uk/catalogue/product.aspx?isbn=159200346Xhttp://oreilly.com/catalog/9780596802486http://www.arduino.cc/en/Main/Softwarehttp://arduino.cc/en/Reference/HomePagehttp://www.sparkfun.com/http://adafruit.com/http://www.makershed.com/http://www.jameco.com/http://creativecommons.org/licenses/by-nc-sa/3.0/http://itp.nyu.edu/itp/http://www.jodyculkin.com/http://arduino.cc/forum/http://www.arduino.cc/en/Main/Creditshttp://itp.nyu.edu/itp/http://oreilly.com/catalog/9780596802486http://edu.cengage.co.uk/catalogue/product.aspx?isbn=159200346Xhttp://oreilly.com/catalog/0636920010920http://oreilly.com/catalog/9780596155520http://www.instructables.com/tag/type-id/category-technology/channel-arduino/http://www.ladyada.net/learn/arduino/http://www.arduino.cc/en/Tutorial/HomePagehttp://www.jameco.com/http://www.makershed.com/http://adafruit.com/http://www.sparkfun.com/http://www.arduino.cc/en/Main/Softwarehttp://arduino.cc/en/Reference/HomePage