Working with Arduino: Lesson #1: Getting Acquainted with the Kit

Slides:



Advertisements
Similar presentations
Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
Advertisements

EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Electrical team Arduino tutorial I BY: JOSHUA arduini
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.
MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
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.
Working with Arduino: Lesson #2: Variable, Photo, and Force Sensitive Resistors EGN1007.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
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
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Working with Arduino: Lesson #3: Force Sensitive Resistors EGN1007.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
chipKit Sense Switch & Control LED
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
Working with Arduino: Lesson #4: Servos EGN1007. Learning Goals Learning Goals: The student will be able to: 1.Build a complete circuit using the Arduino.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.
Microcontrollers, Microcomputers, and Microprocessors
Microcontroller basics Embedded systems for mortals.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 A course developed from the text book: “Introduction to Arduino A Piece of Cake!”
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
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.
INTRODUCTION TO ROBOTICS Part 5: Programming
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Val Manes Department of Math & Computer Science
Microcontroller basics
Arduino & its hardware interfacing
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
Welcome to Arduino A Microcontroller.
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
Control the color and brightness of an RGB LED with a Potentiometer
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Lighting LEDs with a RASPBERRY PI
Arduino 101 Credit(s):
1 Code
Welcome to Digital Electronics using the Arduino Board
The RGB LED.
While Loops and If-Else Structures
Arduino Part #3 Variables
Programming 2: The Arduino IDE & First Sketches
While Loops and If-Else Structures
While Loops and If-Else Structures
Arduino Part 4 Let there be more light.
While Loops and If-Else Structures
CTY SAR FCPS Shawn Lupoli, Elliot Tan
While Loops and If-Else Structures
Aeroponic Engineering and Vertical Farming
Lab #1: Getting Started.
Arduino Uno circuit basics
While Loops and If-Else Structures
Setting up a basic program with Arduino
While Loops And If-Else Structures
Introduction to Arduino IDE and Software
Presentation transcript:

Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007

What is Arduino? Arduino is a popular “open source” single board microcontroller. It is designed to make the process of using electronics in multidisciplinary projects more accessible. This idea began in Italy and its initial purpose was to make STUDENT design projects more affordable than other prototyping projects at the time.

Arduino Software The Arduino programming platform was designed in JAVA to help newcomers become familiar with programming. The language used to write code is C/C++ and only uses TWO functions to make a functionable program.

Programming - Routines Each Arduino program is called a SKETCH and has two required functions, called ROUTINES. void setup ( ) { } - All of the code within the curly braces will be run ONCE when the program first runs. void loop ( ) { } - This function is run AFTER setup has finished. All of the code within the curly braces will be run again, and again, until the power is removed.

Programming - Syntax // - Single line comment Similar to ROBOTC, the formatting requirement is the same. // - Single line comment /* */ - Multiline comment { } – used to define a block of code that starts and ends. ; - used to define the end of a line of code.

Programming - Variables Again the variables used are similar to ROBOTC, with a few exceptions. int (integer) – this stores a number in 2 bytes(16 bits) and has no decimal places. The value must be between -32,768 and 32,768. long(long) – Used when the integer is NOT large enough. This takes 4 bytes(32 bits) of RAM and has a range of -2,147,483,648 and 2,147,483,648. boolean(boolean) – A simple true and false variable. It is useful because it only takes up 1 bit of RAM. float (float) – Used for floating decimals. It takes 4 bytes of RAM and has a range of -3.4028235E+38 and 3.4028235E+38 char(character) – Stores one character using ASCII code (“A” = 65). Uses 1 byte of RAM

Programming – Math Operators These are used for manipulating numbers. = (assignment) makes something equal to something else. For example, x = 10*2, thus x = 20. % (modulo) – this gives the remainder when one number is divided by another. For example 12 % 10 gives 2. + (addition) - (subtraction) * (multiplication) / (division)

Comparison Operators These are used to make logical comparisons. == (equal to) - For example 12==10 is FALSE and 12 ==12 is TRUE. != (not equal to) - For example 12!=10 is TRUE and 12!=12 is FALSE. < (less than) > (greater than)

Programming – Control Structures These execute code based on CONDITIONS. Here are just a few. if(condition) { } else if (condition) { } else(condition) { } This will execute the code between the curly braces if the condition is true, and if not test the condition of the “else if”. If that is false , the “else” code will execute. for (int i =0; i < #repeats; i ++) { } Used when you would like to repeat a line of code a specific # of times. Often called a FOR LOOP.

Programming - Digital pinmode (pin, mode) ; - Used to address the pin # on the Arduino board you would like to use 0-19. The mode can either be INPUT or OUTPUT. digitalwrite (pin, value); - Once a pin is set to output it can be set to either HIGH (5 Volts) or LOW(0 volts). This basically means turn ON and OFF. Note: There are ways to use the board as analog. Those will be explained later.

Let’s Begin – Learning Goals Learning Goals: The student will be able to: Build a complete circuit using the Arduino microprocessor Identify important electrical components in a circuit and explain their use Identify and apply specific elements in “C” code used to run a program in conjunction with how a circuit is built

Scales of Measurement – Do you get it?

Lesson #1 – Blinking LED What will you need? Arduino, breadboard, 4 wires, 10mm LED(large white), 560W resistor, USB cable. Longer Lead is POSITIVE

LEDs An LED (light emitting diode) emits light when a small current passes through it. You can identify it as it looks like a small bulb It only works in ONE direction. So make sure you attach it correctly. Also it often needs a resistor to limit the current going to it. Schematic symbol

Resistors Resistors restrict the amount of electrical current that can flow through a circuit. The color bands indicate the VALUE of the resistor Note: it is easy to grab the WRONG one so be careful. Also, it does not matter which way the resistor is wired. Schematic symbol

The schematic This is basically a SERIES circuit where the resistor and LED are wired one after another. Run a red wire from the 5V on the Arduino to the red strip on the BB. Run a black wire from the GROUND(GND) on the Arduino to the blue strip on the BB. Place the LED on H 22 and 21 with the longer lead(+) of the LED in H22. Place a resistor on I21 and I11. Notice that both the resistor and LED share row 21. Run a red wire from Digital 13 port on Arduino to F22 Run a black wire from J11 to the blue strip.

Writing the code - Integers Load up the Arduino software. Begin by using the variable “int” or integer and let’s tell the Arduino which port the LED is in.

Writing the code - Setup Remember that SETUP is used for things that only need to be done once. Therefore we must tell the Arduino that the LED in port 13 is an output. That means when we input data it outputs an outcome or result.

Writing the code - Loop The next steps is telling the Arduino what we want to do with the LED. We first need to use the digitalWrite command to turn the LED ON. We then use the “delay” command to specify and amount of time in milliseconds. We then use the same command to turn it OFF then wait again. Since this is a loop the process will repeat forever until the power is removed.

Compile To compile your sketch, click the checkmark. Make sure your Arduino is plugged into an available USB port. Click the arrow to download the program to Arduino. If everything is attached correctly. The LED should blink.

Your turn Using what you have learned. Create a new program and record the program on the lesson sheet. Do NOT use more than 1 LED and DO NOT remove the resistor. Leave the circuit as is. Once you have created your own program, follow the directions on the next slide.

Controlling the Brightness Switch the LED pin to #9 (change the integer in the code as well) and then replace with this line in the loop analogwrite(ledPin,new number) Where the “new number” can be any value between 0 and 255. Write and show your new sketch on the project sheet. Compile, download, and test.

Fading Go to FILE, then EXAMPLES, then ANALOG, then FADING. Follow the hyperlink which explain how to FADE. Create a program that uses this idea and record on project sheet. Be sure to explain which C-code element allows this idea to work.