introduction to arduino - an internet of soft...

16
Introduction to Arduino AN INTERNET OF SOFT THINGS 20.05.15

Upload: duongdien

Post on 18-Jul-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Introduction to ArduinoAN INTERNET OF SOFT THINGS 20.05.15

Page 2: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Workshop StructureDay 1

09:30 – 12:30 Introduction to Arduino: boards, inputs /outputs (Tincuta & Steven).

12:30 – 13:30 Lunch break

13:30 - 16:30 Introduction to communication and connectivity platforms: Bluetooth, WiFi, GPS, etc. (Steven & Evtim)

Day 2

09:30 – 12:30 Introduction to sensors: light, temperature, sound, touch, etc. (Tincuta & Steven)

12:30 – 13:30 Lunch break

13:30 – 16:30 Introduction to bio-metric sensors. (Steven & David)

Page 3: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

What is ArduinoArduino is an open-source physical computing platform based on a simple microcontroller a breakout board for the microcontroller, and a development environment for writing software for the board.

It can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs.

The boards can be assembled by hand or purchased preassembled; the open-source IDE can be downloaded for free.

The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment.

Presenter
Presentation Notes
Wiring - Wiring is an open-source programming framework for microcontrollers: http://wiring.org.co/
Page 4: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Not Arduino, rather an Arduino UNO R3

Page 5: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

The Many types of ArduinoCurrently there are 21 official Arduino boards and many, many variants.

A full listing can be found via the following link:

http://www.arduino.cc/en/Main/Products

Page 6: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

ShieldsShields are pre-built circuit boards that fit on top of your Arduino and provide additional capabilities.

Some examples are: controlling motors, connecting to the internet, providing cellular or other wireless communication, controlling an LCD screen, and much more.

Page 7: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

SensorsWith some simple code, the Arduino can control and interact with a wide variety of sensors - things that can measure light, temperature, degree of flex, pressure, proximity, acceleration, carbon monoxide, radioactivity, humidity, barometric pressure, you name it, you can sense it!

Page 8: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Arduino UNO R3The Arduino Uno is a microcontroller board based on the ATmega328

It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button.

http://www.arduino.cc/en/Main/ArduinoBoardUno

Page 9: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

UNO IO PinsEach of the 14 digital pins on the Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions.

They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values).

By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function.

Additionally, some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

Presenter
Presentation Notes
They operate at 5 volts: This is important! A lot of sensors etc. are not 5V tolerant TWI – Two wire interface I2C The Inter-integrated Circuit (I2C) Protocol is a protocol intended to allow multiple “slave” digital integrated circuits (“chips”) to communicate with one or more “master” chips. Like the Serial Peripheral Interface (SPI), it is only intended for short distance communications within a single device. Like Asynchronous Serial Interfaces (such as RS-232 or UARTs), it only requires two signal wires to exchange information.
Page 10: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

UNO Specialised Function PinsSerial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.

Presenter
Presentation Notes
PWM - Pulse Wave Modulation (Servos etc) SPI Serial Peripheral Interface (SPI) is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances. It can also be used for communication between two microcontrollers. MISO (Master In Slave Out) - The Slave line for sending data to the master, MOSI (Master Out Slave In) - The Master line for sending data to the peripherals, SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master and one line specific for every device: SS (Slave Select) - the pin on each device that the master can use to enable and disable specific devices.
Page 11: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

UNO Miscellaneous PinsThere are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.

See also the mapping between Arduino pins and ATmega328 ports. The mapping for the Atmega8, 168, and 328 is identical.

Presenter
Presentation Notes
AREF – Anolog reference
Page 12: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Arduino LeonardoThe Arduino Leonardo is a microcontroller board based on the ATmega32u4.

It has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller

http://www.arduino.cc/en/Main/ArduinoBoardLeonardo

Page 13: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

Arduino MicroThe Arduino Micro is a microcontroller board based on the ATmega32u4

It has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a reset button. It contains everything needed to support the microcontroller

http://www.arduino.cc/en/Main/ArduinoBoardMicro

Page 14: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

The Arduino IDE1. Verify

2. Upload

3. New

4. Open

5. Save

6. Serial Monitor

7. Sketch Name

8. Code Area

9. Message Area:

10. Text Console

11. Board and Serial Port

Presenter
Presentation Notes
Verify: Compiles and approves your code. It will catch errors in syntax (like missing semi-colons or parenthesis). Upload: Sends your code to the RedBoard. When you click it, you should see the lights on your board blink rapidly. New: This buttons opens up a new code window tab. Open: This button will let you open up an existing sketch. Save: This saves the currently active sketch. Serial Monitor: This will open a window that displays any serial information your RedBoard is transmitting. It is very useful for debugging. Sketch Name: This shows the name of the sketch you are currently working on. Code Area: This is the area where you compose the code for your sketch. Message Area: This is where the IDE tells you if there were any errors in your code. Text Console: The text console shows complete error messages. When debugging, the text console is very useful. Board and Serial Port: Shows you what board and the serial port selections
Page 15: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

A Simple SketchBlink, the Arduino equivalent of “hello world”

1. Introductory comments

2. Property & variables

3. setup ()

4. loop ()

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

Presenter
Presentation Notes
The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board. After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control the Arduino board.
Page 16: Introduction to Arduino - An Internet of Soft Thingsaninternetofsoftthings.com/files/2017/03/Arduino_Introduction.pdf · See also the mapping between Arduino pins and ATmega328 ports

The Arduino Starter KitThe starter kit walks you through the basics of using the Arduino in a hands-on way. You'll learn through building several creative projects.

The kit includes a selection of the most common and useful electronic components with a book of 15 projects. Starting the basics of electronics, to more complex projects, the kit will help you control the physical world with sensor and actuators.

You can find all the codes in the Arduino IDE under the menu Examples / Starter KitDownload IDE: http://arduino.cc/en/Main/Software

A selection of video tutorials made by Massimo Banzi for creating projects using the new Arduino Starter Kit can be found here:

https://www.youtube.com/playlist?list=PLT6rF_I5kknPf2qlVFlvH47qHvqvzkknd