Introduction to Arduino Microcontrollers

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

Lab7: Introduction to Arduino
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Embedded Sumo 1T4 – 1T5 UTRA.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
Living with the Lab Using Your Arduino, Breadboard and Multimeter EAS 199A Fall 2011 Work in teams of two!
Intro to Arduino with LilyPad Make a MakerSpace, Artisan’s Asylum Linz Craig, Chris Taylor, Mike Hord & Joel Bartlett.
New Human Computer Interfaces Amnon Dekel HUJI – CSE, Spring 2007 Class 3 March
How to Build a Digital-Physical System-Lab Assegid Kidané Fall 2014.
Introduction.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Embedded Programming and Robotics
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Arduino Part 1 Topics: Microcontrollers Programming Basics: structure and variables Digital Output Analog to Digital Conversion.
Dean Brock, Rebecca Bruce and Susan Reiser, CCSC SE 2009 Using Arduino Material taken from Todbot blog Bionic Arduino Todbot blog Bionic ArduinoTodbot.
Intro to Arduino Zero to Virtual Prototyping in Seven Hours
DPNM Lab., POSTECH 1/29 CS490K - Internet of Things (IoT) Jonghwan Hyun DPNM Lab. Department of Computer Science and Engineering, POSTECH
Ballooning Bundle. What is a Microcontroller? Small computer with a processor core, memory and programmable input/output Continuously repeats software.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Introduction to the Arduino
Arduino 101 Instructors: Ted Markson / Jim Sweeney.
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
Overview What is Arduino? What is it used for? How to get started Demonstration Questions are welcome at any time.
Getting Started With the Arduino Uno
DPNM Lab., POSTECH 1/44 CS490K - Internet of Things (IoT) Jonghwan Hyun DPNM Lab. Department of Computer Science and Engineering, POSTECH
Microcontrollers, Microcomputers, and Microprocessors
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Microcontroller basics Embedded systems for mortals.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Bdps 2 Lecture 2. Circuits and Ohm's Law For resistive circuits.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
Introduction to Arduino Microcontrollers (Death by Powerpoint)
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Having fun with code, using Arduino in a middle school CS classroom
Arduino - Introduction
Arduino.
Getting Started: Building & Programming
By Rick Darby Sponsors: Geekspace Gwinnett The WorkSpot
Overview What is Arduino? What is it used for? How to get started
Prototyping with Microcontrollers and Sensors
Dr. Kyung Eun Park Summer 2017
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
Overview What is Arduino? What is it used for? How to get started
Arduino Development for Beginners
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
Arduino - Introduction
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Analog Input through POT
Arduino and Design of Embedded Applications
Introduction to Arduinos
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
Instructor Resources.
What is Arduino? By James Tedder.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Banyule Coding Club: Learn Arduino Richard Counsel Malcolm Macleod Watsonia Library - June 2018 Reference materials here ->
Arduino programs Arduino toolchain Cross-compilation Arduino sketches
Aeroponic Engineering and Vertical Farming
Introduction to Arduino
Lab #1: Getting Started.
Arduino Uno circuit basics
Introduction to Arduinos
Introduction to arduino
Introduction to Arduino IDE and Software
Instructor Resources.
Presentation transcript:

Introduction to Arduino Microcontrollers Jeff McRaven jamcraven@yahoo.com

Overview Background What To Get (Hardware and Software) Arduino C Microcontroller defined/Why Arduino's? Types of Arduino microcontrollers What To Get (Hardware and Software) Arduino C Electronic Circuits Projects Blinking light(s) Reading inputs (variable resistors)

Microcontrollers – One Definition Programmers work in the virtual world. Machinery works in the physical world. How does one connect the virtual world to the physical world? Enter the microcontroller. A microcontroller is basically a small-scale computer with generalized (and programmable) inputs and outputs. The inputs and outputs can be manipulated by and can manipulate the physical world.

Arduino – Official Definition Taken from the official web site (arduino.cc): Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

Why Arduino? For whatever reason, Arduino microcontrollers have become the de facto standard. Make Magazine features many projects using Arduino microcontrollers. Strives for the balance between ease of use and usefulness. Programming languages seen as major obstacle. Arduino C is a greatly simplified version of C++. Inexpensive ($35 retail).

Arduino Types Many different versions Leonardo Due Micro LilyPad Number of input/output channels Form factor Processor Leonardo Due Micro LilyPad Esplora Uno

Leonardo Compared to the Uno, a slight upgrade. Built in USB compatibility Bugs? Presents to PC as a mouse or keyboard

Due Much faster processor, many more pins Operates on 3.3 volts Similar to the Mega

Micro When size matters: Micro, Nano, Mini Includes all functionality of the Leonardo Easily usable on a breadboard

LilyPad LilyPad is popular for clothing-based projects.

Esplora Game controller Includes joystick, four buttons, linear potentiometer (slider), microphone, light sensor, temperature sensor, three-axis accelerometer. Not the standard set of IO pins.

Mega Compared to the Uno, the Mega: Many more communication pins More memory Some interface hardware doesn't work

Arduino Uno Close Up The pins are in three groups: Invented in 2010 14 digital pins 6 analog pins power

Where to Start Get an Arduino (starter kit) Download the compiler Connect the controller Configure the compiler Connect the circuit Write the program Get frustrated/Debug/Get it to work Get excited and immediately start next project (sleep is for wimps)

Arduino Starter Kits Start with a combo pack (starter kit) Includes a microcontroller, wire, LED's, sensors, etc. www.adafruit.com adafruit.com/products/68 ($65) www.sparkfun.com https://www.sparkfun.com/products/11576 ($99.95) Radio Shack Make Ultimate Microcontroller Pack w/ Arduino Kit ($119.99) www.makershed.com http://www.makershed.com/Ultimate_Arduino_Microcontroller_Pack_p/msump1.htm ($150)

What to Get – My Recommendation Required: Arduino (such as Uno) USB A-B (printer) cable Breadboard Hookup wire LED's Resistors Sensors Switches Good Idea: Capacitors Transistors DC motor/servo Relay Advanced: Soldering iron & solder Heat shrink tubing 9V battery adapter Bench power supply

Arduino Compiler Download current compiler from: arduino.cc/en/Main/software Arrogantly refers to itself as an IDE (Ha!). Run the software installer. Written in Java, it is fairly slow. Visit playground.arduino.cc/Main/ DevelopmentTools for alternatives to the base arduino IDE

Configuring the Arduino Compiler Defaults to COM1, will probably need to change the COM port setting (my work PC uses 7). Appears in Device Manager (Win7) under Ports as a Comm port.

Arduino Program Development Based on C++ without 80% of the instructions. A handful of new commands. Programs are called 'sketches'. Sketches need two functions: void setup( ) void loop( ) setup( ) runs first and once. loop( ) runs over and over, until power is lost or a new sketch is loaded.

Arduino C Arduino sketches are centered around the pins on an Arduino board. Arduino sketches always loop. void loop( ) {} is equivalent to while(1) { } The pins can be thought of as global variables.

Arduino C Specific Functions pinMode(pin, mode) Designates the specified pin for input or output digitalWrite(pin, value) Sends a voltage level to the designated pin digitalRead(pin) Reads the current voltage level from the designated pin analog versions of above analogRead's range is 0 to 1023 serial commands print, println, write

Compiler Features Numerous sample sketches are included in the compiler Located under File, Examples Once a sketch is written, it is uploaded by clicking on File, Upload, or by pressing <Ctrl> U

Arduino C is Derived from C++ These programs blink an LED on pin 13 avr-libc #include <avr/io.h> #include <util/delay.h> int main(void) { while (1) { PORTB = 0x20; _delay_ms(1000); PORTB = 0x00; } return 1; Arduino C void setup( ) { pinMode(13, OUTPUT); } void loop( ) { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW);

Basic Electric Circuit Every circuit (electric or electronic) must have at least a power source and a load. The simplest circuit is a light. Plug in the light, and it lights up. Unplug it, the light goes out. Electricity flows from the power source, through the load (the light) and then back to the power source.

Basic LED Circuit Connect the positive (+) lead of a power source to the long leg of an LED. Connect other leg of the LED to a resistor. High resistance means a darker light. Low resistance means brighter light. No resistance means a burned out LED. Connect other leg of the resistor to the negative lead of the power source.

Let the Good Times Roll! At this point we have: Let's write some code! Purchased a starter kit, including the Arduino Connected and configured the Arduino Connected a simple LED circuit Let's write some code!

Blink Sketch void setup( ) { pinMode(13, OUTPUT); } void loop( ) { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); Connected to one end of the circuit Connected to other end of the circuit GND to ground and 13 to power 330 ohm ground and LED LED to 330 ohm and power

4 LED Blink Sketch void setup( ) { pinMode(1, OUTPUT); } void loop( ) { digitalWrite(1, HIGH); delay (200); digitalWrite(1, LOW); digitalWrite(3, HIGH); digitalWrite(3, LOW); digitalWrite(5, HIGH); digitalWrite(5, LOW); digitalWrite(7, HIGH); digitalWrite(7, LOW); }

So What? Great. Blinking lights. Not impressed. Only covered output thus far. Can use analog inputs to detect a physical phenomena.

Inputs Digital inputs will come to the Arduino as either on or off (HIGH or LOW, respectively). HIGH is 5VDC. LOW is 0VDC. Analog inputs will come to the Arduino as a range of numbers, based upon the electrical characteristics of the circuit. 0 to 1023 .0049 V per digit (4.9 mV) Read time is 100 microseconds (10,000 a second)

Analog Input A potentiometer (variable resistor) is connected to analog pin 0 to an Arduino. Values presented to pin 0 will vary depending upon the resistance of the potentiometer. void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(0));

Analog Input-Application The variable resistor can be replaced with a sensor. For example, a photo resistor. Depending upon the light level at the photo resistor: Turn on a light Increase or decrease the brightness of an LED (or an LED array) Most sensors are simply variable resistors, but vary their resistance based on some physical characteristic. void setup() { pinMode(9, OUTPUT); } void loop() int lightLevel = analogRead(0); lightLevel = map(lightLevel, 0, 900, 0, 255); lightLevel = constrain(lightLevel, 0, 255); analogWrite(9, 255 - lightLevel);

Sensors Sensors can be both binary or a range. Usually, sensors that measure a range of values vary their resistance to reflect their detection. Arduinos can only sense voltages, not resistances. Sensors that only vary their resistances require a circuit called a voltage divider to provide the Arduino a voltage.

Common Sensors Dials on a radio are simply potentiometers Temperature Light Angle Switches did the user throw a switch or push a button? Accelerometer (measures motion and tilt) Infrared sensor & light Hall effect sensor and magnet Ball tilt sensor (for measuring orientation) Force

“Competitors”to the Arduino PIC controller Microcontroller programmed with C or assembler Alternatives to the Arduino line Pinguino – PIC controller MSP430 – Texas Instruments; $4.30 Others: customs, Teensy, etc. Netduino Computers Raspberry Pi BeagleBones – TI; has computer and controller

Netduino Microcontroller and development tools created by Microsoft to work with the .NET Micro Framework. VASTLY better development environment. visualmicro.com Other alternatives Differences Pins on a Netduino are 3.3V (not 5). Netduinos have a much faster processor. 60K of RAM (versus an Uno's 2K). Largely compatible with the Arduino, but it is not a drop-in replacement (can fry it).

Raspberry Pi Low end computer, not a controller Uses Debian Linux Arch Linux ARM, Fedora, FreeBSD, Slackware… Programmed with Python BBC BASIC, C, Perl As it is a computer and not a controller, its role in these projects is different. Hierarchy: computers control controllers, controllers control hardware.

Shields Shields are circuit boards that plug into the top of an Arduino. They extend the capabilities of an Arduino. Examples: Ethernet GPS Motor Prototype shieldlist.org

Conclusion The Arduino microcontroller is a low cost way to enter into the hobby of robotics. The Arduino has two plusses over any other: The user community Extensive online library of code and projects Viewed as the "base" system, upon which all other microcontrollers are built. Compatibility. So get a kit, and start ushering in the inevitable takeover of our robotic overlords!

Introduction to Arduino Microcontrollers Jeff McRaven jamcraven@yahoo.com