Arduino & its hardware interfacing

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.
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
How to use Arduino By: Andrew Hoffmaster.
Embedded Sumo 1T4 – 1T5 UTRA.
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
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.
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.
Lesson 3 — How a Computer Processes Data
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.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
INTRODUCTION TO ROBOTICS Part 5: Programming Robotics and Automation Copyright © Texas Education Agency, All rights reserved. 1.
SAMI MAKERSPACE MAKE: AN ELECTRONICS WORKSHOP. ARDUINO BASICS Credit to: Sparkfun and Linz Craig, Nick Poole, Prashanta Aryal, Theo Simpson, Tai Johnson,
Microcontrollers, Microcomputers, and Microprocessors
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Week 5: Microcontrollers & Flow Control Bryan Burlingame 2 March 2016.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
IC 3 BASICS, Internet and Computing Core Certification Computing Fundamentals Lesson 2 How Does a Computer Process Data?
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.
Introduction to Programming the Arduino Dr Gaw 3/21/14.
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.
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.
Arduino Programming. THE ARDUINO IS A MICROCONTROLLER – A LOW COST, LOW PERFORMANCE COMPUTER.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Arduino.
INTRODUCTION TO ROBOTICS Part 5: Programming
Michael Rahaim, PhD Candidate Multimedia Communications Lab
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Dr. Kyung Eun Park Summer 2017
Val Manes Department of Math & Computer Science
Microcontroller basics
Arduino Programming Part II
Microcontroller basics
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Lecture 2-2: Arduino Programming
Introduction to Arduino Microcontrollers
Introduction to Arduinos
Roller Coaster Design Project
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.
What is an Arduino ? Open Source electronic prototyping platform based on flexible easy to use hardware and software.
FeMaidens Programming
Arduino 101 Credit(s):
1 Code
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Topics: Programming Constructs: loops & conditionals Digital Input
Arduino : Introduction & Programming
Intro to the Arduino by Someet Singh
Programming 2: The Arduino IDE & First Sketches
Aeroponic Engineering and Vertical Farming
Arduino Uno circuit basics
Setting up a basic program with Arduino
Introduction to Arduinos
SAURABH GINGADE.
Model Blimp Design Competition Programming Workshop by Youth College (International) / VTC May
Introduction to arduino
Introduction to Arduino IDE and Software
Presented By,  Mamata Yadav (BE Elex & Comm.) Vice R&D Coordinator(HW), PCRT  Payal Shah (BE Elex & Comm.)  Ananta Das (BE Elex & Comm.) R&D Team,PCRT.
Presentation transcript:

Arduino & its hardware interfacing

What is an Arduino ? Arduino. A microcontroller board, contains on-board power supply, USB port to communicate with PC, and an Atmel microcontroller chip. It simplify the process of creating any control system by providing the standard board that can be programmed and connected to the system without the need to any sophisticated PCB design and implementation. It is an open source hardware, any one can get the details of its design and modify it or make his own one himself. Arduino.

Arduino boards: UNO Mega LilyPad Arduino BT Arduino Nano Arduino Mini

Atmel MicroController Arduino UNO: Digital output ~: PWM. 0,1: Serial port. In circuit Serial programming Atmel MicroController USB port Power input Analog input. Power Supply

Arduino is a platform Also including an Integrated Development Environment (IDE) for programming. The language itself is based in C but is largely modeled upon the www.processing.org language.

Advantages of Aurdino Open source Simplified and user-friendly programming language No additional programmer/burner hardware required for programming board Portable Low power consumption

Arduino vs other environments Support for analog input Limited Computing power Comparatively cheap Limited memory PWM output available Open source

Arduino Coding 2

Data Types and operators Integer: used with integer variables with value between 2147483647 and -2147483647. Ex: int x=1200; Character: used with single character, represent value from -127 to 128. Ex. char c=‘r’; Long: Long variables are extended size variables for number storage, and store 32 bits (4 bytes), from -2,147,483,648 to 2,147,483,647. Ex. long u=199203; Floating-point numbers can be as large as 3.4028235E+38 and as low as -3.4028235E+38. They are stored as 32 bits (4 bytes) of information. Ex. float num=1.291; [The same as double type]

Statement and operators: Statement represents a command, it ends with ; Ex: int x; x=13; Operators are symbols that used to indicate a specific function: - Math operators: [+,-,*,/,%,^] - Logic operators: [==, !=, &&, ||] - Comparison operators: [==, >, <, !=, <=, >=] Syntax: ; Semicolon, {} curly braces, //single line comment, /*Multi-line comments*/

Statement and operators: Compound Operators: ++ (increment) -- (decrement) += (compound addition) -= (compound subtraction) *= (compound multiplication) /= (compound division)

Control statements: If Conditioning: if(condition) { statements-1; … Statement-N; } else if(condition2) Statements; Else{statements;}

Control statements: Switch case: switch (var) { case 1: //do something when var equals 1 break; case 2: //do something when var equals 2 default: // if nothing else matches, do the default // default is optional }

Loop statements: Do… while: do { Statements; } while(condition); // the statements are run at least once. While: While(condition) {statements;} for for (int i=0; i <= val; i++){ statements; Use break statement to stop the loop whenever needed.

Code structure: Void setup(){} Used to indicate the initial values of system on starting. Void loop(){} Contains the statements that will run whenever the system is powered after setup.

Input and output: pinMode(); digitalRead(); digitalWrite(); delay(time_ms); other functions: analogRead(); analogWrite();//PWM.

Hardware interfacing A hardware interface specifies the plugs, sockets, cables and electrical signals that pass through each line between the CPU and a peripheral device or communications network.  Next slide Example of hardware interfacing project home automation by android

Project Components

Relay Test

Relay testing code #define relay 2 //attaches the relay to pin 2 void setup() { pinMode(relay, OUTPUT); //sets the relay as an output } void loop() { digitalWrite(relay, HIGH); //relay open delay(2000); //wait 2 seconds digitalWrite(relay, LOW); //relay closed delay(2000); //wait 2 seconds }

Bluetooth Test

Final hardware code part 1 String voice; #define relay1 2 #define relay2 3 void setup() { Serial.begin(9600); pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); digitalWrite(relay1, LOW); digitalWrite(relay2, LOW); } void loop() { if(Serial.readString() && voice.length() >0){ if(voice == "*switch on"){ switchon(); } else if(voice == "*switch off"){ switchoff(); }

Final hardware code part 1 else if(voice == "*lamp on"){ digitalWrite(relay1, HIGH); } else if(voice == "*lamp off"){digitalWrite(relay1, LOW); } else if(voice == "*kettle on"){ digitalWrite(relay2, HIGH); } else if(voice == "*kettle off"){ digitalWrite(relay2, LOW); } } } void switchon() { digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH); } void switchoff() { digitalWrite(relay1, LOW); digitalWrite(relay2, LOW);

Final hardware code part 2 String voice; #define relay1 2 //Connect relay1 to pin 2 #define relay2 3 //Connect relay2 to pin 3 void setup() { Serial.begin(9600); //Set rate for communicating with phone pinMode(relay1, OUTPUT); //Set relay1 as an output pinMode(relay2, OUTPUT); //Set relay2 as an output digitalWrite(relay1, LOW); //Switch relay1 off digitalWrite(relay2, LOW); //Swtich relay2 off } void loop() { while(Serial.available()) //Check if there are available bytes to read { delay(10); //Delay to make it stable char c = Serial.read(); //Conduct a serial read if (c == '#'){ break; //Stop the loop once # is detected after a word } voice += c; //Means voice = voice + c }

Final hardware code part 2 if (voice.length() >0) { Serial.println(voice); if(voice == "*switch on") { switchon(); } //Initiate function switchon if voice is switch on else if(voice == "*switch off"){ switchoff(); } //Initiate function switchoff if voice is switch off else if(voice == "*lamp on"){ //You can replace 'lamp on' with anything you want...same applies to others digitalWrite(relay1, HIGH); } else if(voice == "*lamp off"){ digitalWrite(relay1, LOW); }

Final hardware code part 2 else if(voice == "*kettle on"){ digitalWrite(relay2, HIGH); } else if(voice == "*kettle off"){ digitalWrite(relay2, LOW); } voice=""; } } void switchon() //Function for turning on relays { digitalWrite(relay1, HIGH); digitalWrite(relay2, HIGH); } void switchoff() //Function for turning on relays { digitalWrite(relay1, LOW); digitalWrite(relay2, LOW); } /* You can add any function you want depending on how many devices you have hooked up. For example you could have a function called 'cinema' which would dim the lights and turn the TV on. You can have as many as you have pins on your arduino. For my relay 'LOW' turns off and 'HIGH' turns on The outline to follow is this: void ......() { digitalWrite(...., LOW/HIGH); }

Application for the code https://play.google.com/store/apps/details?id=robotspace.simplelabs.amr_voice&hl=en you can use those two final code part 1 or part 2 for this application.

This was the simple basic project home automation with help of this presentation you can make voice home automation project … Thanks. Regard Mirza taimoor.