ARDUINO FRAMEWORK.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
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
Lecture 1 – Arduino Basics
Lab7: Introduction to Arduino
Mini-SumoBot Construction and Programming
Arduino Real Time Data Download Arduino Mega2560: Download.
Servo Background Servos provide control of rotary position Servos are used extensively in the remote control hobby world for: Aircraft (flaps, ailerons,
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.
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.
chipKit Sense Switch & Control LED
Practical Electronics & Programming
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
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
Designing with Components Wilmer Arellano. How to chose a Microcontroller Choose one that you are familiar with or that is easy to learn.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Code The Arduino Environment.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
ATtiny Programming Shield for Arduino TYWu. Reference Programming-Shield-for-Arduino-1/
Quick guide to ASIMON configuration For version 3.0 or greater SAFETY AT WORK Date: 3/18/2009.
Arduino libraries Datatekniker Udvidet hardware/software.
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.
C# SERIAL COMMUNICATION TEMPERATURE CONTROL WITH ARDUINO KAAN EREN
Microcontroller basics Embedded systems for mortals.
Microcontroller basics Embedded systems for mortals.
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
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
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).
Introduction to Programming the Arduino Dr Gaw 3/21/14.
Arduino Programming Part 6: LCD Panel Output ME 121 Portland State University.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Pulse Width Modulation Instructor Dr Matthew Khi Yi Kyaw.
Using a SparkFun™ serial LCD with an Arduino
Getting Started: Building & Programming
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Val Manes Department of Math & Computer Science
Microcontroller basics
Introduction to the Arduino
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
European Robotic LABoratory
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Arduino Uno and sensors
Introduction to Arduinos
Roller Coaster Design Project
What is an Arduino ? Open Source electronic prototyping platform based on flexible easy to use hardware and software.
IoT Programming the Particle Photon.
Arduino : Introduction & Programming
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
Arduino程式範例.
Introduction to Arduino IDE and Software
Presentation transcript:

ARDUINO FRAMEWORK

ARDUINO - REVIEW Open http://arduino.cc/ to download the latest version of Arduino IDE

Verify Checks your code for errors. Upload Compiles your code and uploads it to the Arduino I/O board. See uploading below for details. Note: If you are using an external programmer, you can hold down the "shift" key on your computer when using this icon. The text will change to "Upload using Programmer" New Creates a new sketch. Open Presents a menu of all the sketches in your sketchbook. Clicking one will open it within the current window. Note: due to a bug in Java, this menu doesn't scroll; if you need to open a sketch late in the list, use the File | Sketchbook menu instead. Save Saves your sketch. Serial Monitor Opens the serial monitor.

BARE MINIMUM CODE void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly:

DIGITAL READ SERIAL

The code for Digital Read int pushButton = 2; void setup() {   Serial.begin(9600);     pinMode(pushButton, INPUT); } void loop() {   // read the input pin:   int buttonState = digitalRead(pushButton);   // print out the state of the button:   Serial.println(buttonState); }

ANALOG READ SERIAL

Code for Analog Read void setup() {     Serial.begin(9600); } void loop() {   // read the input on analog pin 0:   int sensorValue = analogRead(A0);   // print out the value you read:   Serial.println(sensorValue); }

FADING

Code for Fading int ledPin = 9;    // LED connected to digital pin 9 void setup()  { } void loop()  {     for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {       analogWrite(ledPin, fadeValue);                 delay(30);                               }     for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {         analogWrite(ledPin, fadeValue);              delay(30);                               } }

LCD Connect

Code #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() {   // set up the LCD's number of columns and rows:   lcd.begin(16, 2);   // Print a message to the LCD.   lcd.print("hello, world!"); } void loop() {   // set the cursor to column 0, line 1   // (note: line 1 is the second row, since counting begins with 0):   lcd.setCursor(0, 1);   // print the number of seconds since reset:   lcd.print(millis()/1000); }

Accelerometers

const int groundpin = 18;             // analog input pin 4 -- ground const int powerpin = 19;              // analog input pin 5 -- voltage const int xpin = A3;                  // x-axis of the accelerometer const int ypin = A2;                  // y-axis const int zpin = A1;                  // z-axis (only on 3-axis models) void setup() {   Serial.begin(9600);     pinMode(groundpin, OUTPUT);   pinMode(powerpin, OUTPUT);   digitalWrite(groundpin, LOW);   digitalWrite(powerpin, HIGH); } void loop() {    Serial.print(analogRead(xpin));   Serial.print("\t");   Serial.print(analogRead(ypin));    Serial.print("\t");   Serial.print(analogRead(zpin));   Serial.println();     delay(100); } Code

Another Accelerometer (Pulse-width based)

const int xPin = 2;     // X output of the accelerometer const int yPin = 3;     // Y output of the accelerometer void setup() {     Serial.begin(9600);     pinMode(xPin, INPUT);   pinMode(yPin, INPUT); } void loop() {   // variables to read the pulse widths:   int pulseX, pulseY;   // variables to contain the resulting accelerations   int accelerationX, accelerationY;     // read pulse from x- and y-axes:   pulseX = pulseIn(xPin,HIGH);     pulseY = pulseIn(yPin,HIGH);     // convert the pulse width into acceleration   // accelerationX and accelerationY are in milli-g's:   // earth's gravity is 1000 milli-g's, or 1g.   accelerationX = ((pulseX / 10) - 500) * 8;   accelerationY = ((pulseY / 10) - 500) * 8;   // print the acceleration   Serial.print(accelerationX);   // print a tab character:   Serial.print("\t");   Serial.print(accelerationY);   Serial.println();   delay(100); } Code

WEB CLIENT #include <SPI.h> #include <Ethernet.h> // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192,168,1, 177); // Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): EthernetServer server(80); void setup() {   Serial.begin(9600);   // start the Ethernet connection and the server:   Ethernet.begin(mac, ip);   server.begin();   Serial.print("server is at ");   Serial.println(Ethernet.localIP()); }

void loop() {   // listen for incoming clients   EthernetClient client = server.available();   if (client) {     Serial.println("new client");     // an http request ends with a blank line     boolean currentLineIsBlank = true;     while (client.connected()) {       if (client.available()) {         char c = client.read();         Serial.write(c);         // if you've gotten to the end of the line (received a newline         // character) and the line is blank, the http request has ended,         // so you can send a reply         if (c == '\n' && currentLineIsBlank) {           // send a standard http response header           client.println("HTTP/1.1 200 OK");           client.println("Content-Type: text/html");           client.println("Connnection: close");           client.println();           client.println("<!DOCTYPE HTML>");           client.println("<html>");                     // add a meta refresh tag, so the browser pulls again every 5 seconds:           client.println("<meta http-equiv=\"refresh\" content=\"5\">");        

  // output the value of each analog input pin           for (int analogChannel = 0; analogChannel < 6; analogChannel++) {             int sensorReading = analogRead(analogChannel);             client.print("analog input ");             client.print(analogChannel);             client.print(" is ");             client.print(sensorReading);             client.println("<br />");                 }           client.println("</html>");           break;         }         if (c == '\n') {           // you're starting a new line           currentLineIsBlank = true;         }         else if (c != '\r') {           // you've gotten a character on the current line           currentLineIsBlank = false;         }       }     }     // give the web browser time to receive the data     delay(1);     // close the connection:     client.stop();     Serial.println("client disonnected");   } }