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.

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.
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.
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.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
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
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Microcontrollers, Microcomputers, and Microprocessors
Arduino libraries Datatekniker Udvidet hardware/software.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
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!”
:Blink Blink: Er. Sahil Khanna
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
ME 120: Arduino Programming Arduino Programming Part 1 ME 120 Mechanical and Materials Engineering Portland State University
Using a SparkFun™ serial LCD with an Arduino
Arduino.
Getting Started: Building & Programming
INTRODUCTION TO ROBOTICS Part 5: Programming
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Microcontroller basics
Val Manes Department of Math & Computer Science
Microcontroller basics
Arduino & its hardware interfacing
Arduino Programming Part II
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
Cascade switching of an LED
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Lecture 2-2: Arduino Programming
Arduino.
Въведение в Arduino.
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Roller Coaster Design Project
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Arduino 101 Credit(s):
using the Arduino to make LEDs flash
1 Code
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Arduino Part #3 Variables
Programming 2: The Arduino IDE & First Sketches
Arduino Part 4 Let there be more light.
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Multiplexing seven-segment displays
Aeroponic Engineering and Vertical Farming
Lab #1: Getting Started.
Arduino Uno circuit basics
Setting up a basic program with Arduino
SAURABH GINGADE.
UNIT 1 First programs.
Arduino程式範例.
Introduction to Arduino IDE and Software
Presentation transcript:

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 being created from scratch

3 Blink A simple code used to blink an LED plugged into pin 13 The following slides will go through the ‘blink’ code in detail, line by line

4 Comments The first lines of code are displayed in gray This indicates that they are comments for humans to read and not part of the actual code

5 Comments There are 2 ways to incorporate a comment into a code // ….. - Single line comment /* ….. */ - Multiline comment

6 Variables The next line of code introduces a variable called ‘led’ and sets it equal to 13 The name of the variable is chosen by the programmer In this case ‘ x = 13 ’ or ‘ table = 13’ would all suffice It is common to choose a variable name that correlates to what it is being used for In this case 13 will represent the pin the LED is plugged into

7 Variables The word ‘int’ preceding the variable name is used to tell the Arduino what we plan on storing in the variable ‘led’ ‘int’ type can store any integer between ±32,768. It cannot store a fraction or decimal ‘long’ type has a range of ± 2,147,483,648. However, it uses up more memory ‘float’ type has a range of ± E+38. It can contain decimals

8 Routines Each Arduino program is called a SKETCH and has two required functions, called ROUTINES. One is the ‘setup’ and one is the ‘loop’ Each routine contains all of its coding within curly braces void setup ( ) { } - runs once when the program begins void loop ( ) { } - runs repeatedly forever

9 pinMode In this routine there is only one line of code, ‘ pinMode ’ Each digital pin, 0 – 13, needs to be declared as either INPUT or OUTPUT An Input is constantly waiting to absorb voltage while an OUTPUT is waiting to be told to supply it outward In this case pin 13, with an LED, is an Output. We use the ‘led’ in place of ‘13’ since we already declared led = 13 ;

10 digitalWrite The next piece of code is the ‘void loop’ routine of the sketch An output pin can be set HIGH (5v ON) or LOW (0v OFF) using the digitalWrite command We declared led = 13 so we can write ‘led’ as the pin # HIGH means to turn on the pin, or send out 5V through pin 13

11 delay The ‘ delay ’ function causes the Arduino to pause delay is measured in milliseconds, so 1000 = 1 second In this ‘loop’ the first line turns on a LED plugged into pin 13, and the second line tells the controller to wait for 1 second

12 Run 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.