Intro to the Arduino Topics: The Arduino Digital IO Data Representation Serial Communication

Click here to load reader

  • date post

    11-Jan-2016
  • Category

    Documents

  • view

    220
  • download

    0

Embed Size (px)

Transcript of Intro to the Arduino Topics: The Arduino Digital IO Data Representation Serial Communication

  • Intro to the ArduinoTopics: The ArduinoDigital IOData RepresentationSerial Communication

  • Topic 1: Meet Arduino Uno

  • What is the Arduinotodbot.com/blog/bionicarduino

  • Getting StartedCheck out: http://arduino.cc/en/Guide/HomePageDownload & install the Arduino environment (IDE)(not needed in lab)Connect the board to your computer via the USB cableIf needed, install the drivers (not needed in lab)Launch the Arduino IDESelect your boardSelect your serial portOpen the blink example Upload the program

  • Arduino IDESee: http://arduino.cc/en/Guide/Environment for more information

  • Select Serial Port and Board

  • Status Messagestodbot.com/blog/bionicarduino

  • todbot.com/blog/bionicarduino

  • Input/OutputImage from Theory and Practice of Tangible User Interfaces at UC Berkley

  • Topic 2: Digital Input/OutputDigital IO is binary valuedits either on or off, 1 or 0Internally, all microprocessors are digital, why?

    10

  • IO PinsImage from Theory and Practice of Tangible User Interfaces at UC Berkley

  • Arduino Digital I/0pinMode(pin, mode)Sets pin to either INPUT or OUTPUT

    digitalRead(pin)Reads HIGH or LOW from a pin

    digitalWrite(pin, value)Writes HIGH or LOW to a pin

    Electronic stuff Output pins can provide 40 mA of currentWriting HIGH to an input pin installs a 20K pullup

    www.mikroe.com/chapters/view/1

  • Our First Program

  • Topic 3: Data RepresentationYou know how information is encoded in 0s and 1s (ECE109)Lets look at the data types for programming the Arduino:

  • An ExampleWhat output would be generated?This will be explained laterThis prints to the screen

  • Topic 4: Serial CommunicationImage from http://www.ladyada.net/learn/arduino/lesson4.html

  • todbot.com/blog/bionicarduino

  • Serial CommunicationCompiling turns your program into binary data (ones and zeros)Uploading sends the bits through USB cable to the Arduino The two LEDs near the USB connector blink when data is transmittedRX blinks when the Arduino is receiving dataTX blinks when the Arduino is transmitting data

    todbot.com/blog/bionicarduino

  • Open the Serial Monitor and Upload the Program

  • Some CommandsSerial.begin() - e.g., Serial.begin(9600)Serial.print() or Serial.println() - e.g., Serial.print(value)Serial.read()Serial.available()Serial.write()Serial.parseInt()Example Program

  • Serial-to-USB chip---what does it do?

    Image from Theory and Practice of Tangible User Interfaces at UC Berkley The LilyPad and Fio Arduino require an external USB to TTY connector, such as an FTDI cable.In the Arduino Leonardo a single microcontroller runs the Arduino programs and handles the USB connection.

  • Two different communication protocolsSerial (TTL): Image from http://www.fiz-ix.com/2013/02/introduction-to-arduino-serial-communication/

  • USB ProtocolMuch more complicatedImage from http://en.wikipedia.org/wiki/USB

    **