Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Advertisements

Lecture 1 – Arduino Basics
Lab7: Introduction to Arduino
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
How to use Arduino By: Andrew Hoffmaster.
Embedded Sumo 1T4 – 1T5 UTRA.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
Living with the Lab Using Your Arduino, Breadboard and Multimeter EAS 199A Fall 2011 Work in teams of two!
Arduino. Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source.
1 Arduino Board: Arduino UNO Arduino Programing Environment: Arduino 0022
Introduction.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Embedded Programming and Robotics
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Colorado Space Grant Consortium Gateway To Space ASEN 1400 / ASTR 2500 Class #12 Gateway To Space ASEN 1400 / ASTR 2500 Class #12 T-58.
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
Programming Hexors on Arduino Uno. Arduino Uno Arduino is an open-source electronics platform based on easy- to-use hardware and software. It's intended.
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
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
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Overview What is Arduino? What is it used for? How to get started Demonstration Questions are welcome at any time.
WELCOME TO ARDUINO E-DAY CAR PROJECT MEETING – ITALY MARCH.
SAMI MAKERSPACE MAKE: AN ELECTRONICS WORKSHOP. ARDUINO BASICS Credit to: Sparkfun and Linz Craig, Nick Poole, Prashanta Aryal, Theo Simpson, Tai Johnson,
Who Are You, Arduino? Er. Sahil Khanna
Microcontrollers, Microcomputers, and Microprocessors
Arduino The Internet of Things: Using the Arduino to Teach Coding.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo).
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
ECE Group Members Samantha Starr BME Arduino Arianna Weinshel BME Sensors, Circuits Eden Woldemichael CE AM Radio Taylor Brooke EE Instrumentation,
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Having fun with code, using Arduino in a middle school CS classroom
Arduino.
Getting Started: Building & Programming
By Rick Darby Sponsors: Geekspace Gwinnett The WorkSpot
Assist. Prof. Rassim Suliyev - SDU 2017
Microcontroller basics
Val Manes Department of Math & Computer Science
Microcontroller basics
Microprocessors Tutorial 1: Arduino Basics
UTA010 : Engineering Design – II
Get Your Project Started with Arduino
Arduino Development for Beginners
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Control the color and brightness of an RGB LED with a Potentiometer
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Roller Coaster Design Project
Roller Coaster Design Project
What is Arduino? By James Tedder.
Arduino 101 Credit(s):
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Arduino : Introduction & Programming
Arduino Part 4 Let there be more light.
Sensors and actuators Sensors Resistive sensors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Introduction to Arduino
Lab #1: Getting Started.
Arduino Uno circuit basics
Presentation transcript:

Introduction to Arduino Prepared by R. Lamond

 “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” (arduino.cc)  Consists of both software and hardware: ◦ Software: The Arduino language (a variant of C) ◦ Hardware: The Arduino Uno in our case (other boards exist)

 Gather sensor data  Actuate servos  Process image data and light LEDs  Communicate with smartphones for home automation  Many, many more possibilities! Arduino (or a similar microcontroller) may be crucial to your senior design project!

USB PORT Digital / PWM Ports Analog PortsPower Ports Microprocessor 5 V We’ll talk about the Arduino later on.

 Basic Arduino code has three general sections: ◦ Variable declaration: int x = 3; //this is a comment! int y = 0; //ect… ◦ Setup Loop: void setup() ◦ { //This code runs before everything else. //pin setup and communications setup pinMode(x, OUTPUT); } ◦ Main program loop: This is where the majority of your code goes! void loop() ◦ { y=x; //ect… }

 Arduino syntax is quite similar to interactive C as they are both “C-based” languages  If you get confused about syntax today, think back to your work with robots!  Arduino commands are quite different from IC, so you may have to consult references (or your instructor) to determine the proper usage.

 Become familiar with the Arduino Uno and Language: ◦ Understand and upload some sample code to the Arduino Uno ◦ Understand and edit some more complex code, modify it to add functionality, and upload to the Arduino Uno

 But what are we actually making? ◦ A hardware/software system which makes a single color LED blink on and off ◦ A hardware/software system which makes three colored LEDs pulse between very dim and very bright  What parts will we need? ◦ 1 computer ◦ 1 Arduino Uno Board ◦ 1 RGB LED ◦ 1 Breadboard ◦ 3 Resistors (2 x 100Ω, 1 x 180 Ω)

 PWM: Pulse Width Modulation ◦ A simple way of mimicking an analog signal using a digital one ◦ Very useful for devices which lack an analog output (like Arduino!)  To power an LED, we need an analog voltage (in this case, approximately >2.5 V)  Arduino has PWM built in for voltages between 0V and 5V  5V = a PWM value of 255  0V = a PWM value of 0  You can use any value between 0 and 255 for PWM on an Arduino

 LEDs are very sensitive to changes in current  The current in an LED varies exponentially with voltage, therefore small increases in voltage are potentially dangerous!  Resistors vary linearly with voltage  Using a resistor in series with an LED will limit the current through the LED, minimizing the risk of damage

 First Step: Walk through the code step by step  Second Step: Learn how to download code to the Arduino  Third Step: Understand the hardware setup

//PART 1: Reading and running basic Arduino code //Variable Declaration int LED = 3; //Define which port on the Arduino board will be used int toggle = 0; //Setup a variable which turns the LED on and off void setup() //All arduino programs have setup loops. This code runs before everything else. Put pin setup and communications setup code here { pinMode(LED, OUTPUT); //Defining the port (or pin, interchangable) we decide upon as an output of the Arduino board } void loop() //Loops contain the majority of Arduino code, your main program will go within this structure. { //The following logic flips our "toggle" variable between 0 and 255 //As we learned in class, 255 is the maximum value for PWM ports on the Arduino board, meaning a PWM port set at 255 will output a constant 5 volts if (toggle == 0) { toggle = 255; } else if (toggle == 255) { toggle = 0; } analogWrite(LED, toggle); //Here, we send the new value of toggle to the port LED (which we defined as port 3 on line 1). delay(500); //Wait 500 milliseconds before restarting the loop; this way we get a flashing LED! }//Make sure to close your brackets!

 Connect the Arduino to your PC via the USB cable  Open the Arduino software (arduino.exe)  This is where you can write/edit your code ◦ It will tell you if there are errors during compilation  Press the check mark to compile your code  Press the right facing arrow to download your code to the board

 You may have to change the COM port through which the software and Arduino board communicate  Ask your GTA for help if there is any confusion

 Three colors for the price of one!  This is a “common anode” LED, meaning that all three LEDs share a ground connection (you only need to ground one wire to ground all three LEDs)

PORT 3 GROUND

 Check out an Arduino from your GTA and a USB cable from the lab techs  Build the device we just discussed  Don’t hesitate to ask when you have questions!  Next: using all three colors!

 We want to make a device which features all three colors on the LED fading from dim to bright  You will be given the majority of the code for the code for the red and green LEDs; your assignment will be to add code to activate the blue LED as well.  First, build the circuit on the next slide and download the following code to your board to see what it does.

//PART 2: Modifying existing code to gain understanding //you need to add the blue LED code int REDPin = 3; // RED pin of the LED to PWM pin 3 int GREENPin = 5; // GREEN pin of the LED to PWM pin 5 // BLUE pin of the LED to PWM pin 6 int brightness = 0; // LED brightness int increment = 5; // brightness increment (changing this will change the smoothness of transitions) void setup() { pinMode(REDPin, OUTPUT); pinMode(GREENPin, OUTPUT); //blue pin mode definition } void loop() { brightness = brightness + increment; // increment brightness for next loop iteration if (brightness = 255) // reverse the direction of the fading { increment = -increment; } brightness = constrain(brightness, 0, 255); //function which limits a value to a range analogWrite(REDPin, brightness); analogWrite(GREENPin, brightness); //blue pin value refresh delay(20); // wait for 20 milliseconds to see the dimming effect }

 Ask your GTA if anything is unclear.  When you finish, return your Arduino IN ITS BOX!

   ambient-tv-lighting ambient-tv-lighting