aurdidino1 anurag preetirajesh-sgsits

17
Intro to the Arduino Topics: The Arduino Digital IO Analog IO Serial Communication

Upload: anurag278

Post on 16-Apr-2017

50 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Aurdidino1  anurag preetirajesh-sgsits

Intro to the Arduino

Topics: The ArduinoDigital IOAnalog IO Serial Communication

Page 2: Aurdidino1  anurag preetirajesh-sgsits

Topic 1: Meet Arduino Uno

Page 3: Aurdidino1  anurag preetirajesh-sgsits

Getting Started• Check out: http://arduino.cc/en/Guide/HomePage

1. Download & install the Arduino environment (IDE)(not needed in lab)

2. Connect the board to your computer via the USB cable

3. If needed, install the drivers (not needed in lab)4. Launch the Arduino IDE5. Select your board6. Select your serial port7. Open the blink example 8. Upload the program

Page 4: Aurdidino1  anurag preetirajesh-sgsits

Arduino IDE

See: http://arduino.cc/en/Guide/Environment for more information

Page 5: Aurdidino1  anurag preetirajesh-sgsits

Select Serial Port and Board

Page 6: Aurdidino1  anurag preetirajesh-sgsits

todbot.com/blog/bionicarduino

Page 7: Aurdidino1  anurag preetirajesh-sgsits

Input/Output

Image from Theory and Practice of Tangible User Interfaces at UC Berkley

Page 8: Aurdidino1  anurag preetirajesh-sgsits

Topic 2: Digital Input/Output

• Digital IO is binary valued—it’s either on or off, 1 or 0

• Internally, all microprocessors are digital, why?

1

0

Page 9: Aurdidino1  anurag preetirajesh-sgsits

Arduino Digital I/0

pinMode(pin, mode)Sets pin to either INPUT or OUTPUTdigitalRead(pin)Reads HIGH or LOW from a pindigitalWrite(pin, value)Writes HIGH or LOW to a pinElectronic stuff Output pins can provide 40 mA of currentWriting HIGH to an input pin installs a 20KΩ pullup

www.mikroe.com/chapters/view/1

Page 10: Aurdidino1  anurag preetirajesh-sgsits

Our First Program

Page 11: Aurdidino1  anurag preetirajesh-sgsits

Assignment 1: Digital IO

• Use a push-button to turn ON/Off LED

Page 12: Aurdidino1  anurag preetirajesh-sgsits

Note

• Assignments and quiz are to be submitted by 5th August 2016 on line

Page 13: Aurdidino1  anurag preetirajesh-sgsits

Some Commands• Serial.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

Page 14: Aurdidino1  anurag preetirajesh-sgsits

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.

Page 15: Aurdidino1  anurag preetirajesh-sgsits

Assignment 2: Serial Communication

Modify your program from in-class exercise 2-part 2 to control the intensity of the LED attached to pin 9 based on keyboard input.

Use the Serial.parseInt() method to read numeric keyboard input as an integer.

An input of 9 should produce full intensity and an input of 0 should turn the LED off.

Page 16: Aurdidino1  anurag preetirajesh-sgsits

Arduino QuizQuestion 1:What license is Arduino distributed under?(a) Proprietary with GNU GPL Ambient user interface(b) Proprietary (c)Shareware(d) LGPL or GPL license

(a) Cross-platform(b) Mac OS X (c)Linux(d) Embedded System

Question 2: Which of the following platforms does Arduino run on?

Page 17: Aurdidino1  anurag preetirajesh-sgsits

Question 5: The Arduino IDE is a ________ application written inJava which is derived from the IDE made for the Processingprogramming language and the Wiring project.(a)(Computer(b)Linux(c)Cross-platform(d)OpenOffice.org

Question 4: A typical first program for a microcontroller is to simply blink a ________ on and off.(a)Fluorescent lamp (b)Gas-discharge lamp(c)LED lamp(d)Light-emitting diode

Question 3: They have different connectors for power and I/O, such as a series of pins on the underside of the board for use with ________ for easy prototyping, or more specific connectors.(a)Breadboard(b)Integrated circuit(c)Capacitor(d)Prototype