ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
Lab7: Introduction to Arduino
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
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.
Intro to Arduino with LilyPad Make a MakerSpace, Artisan’s Asylum Linz Craig, Chris Taylor, Mike Hord & Joel Bartlett.
Intro to Programming and Microcontrollers. Activity Group into pairs and sit back-to-back. Pick one person who is going to draw. The other person will.
Introduction to Sensor Technology Week Four Adam Taylor
ARDUINO 1 By Wilmer Arellano. Arduino  Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.
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 PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
ARDUINO 1 By Wilmer Arellano (Under Development).
ARDUINO 1 Under Development. Arduino  Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.
Lecture 9: Microcontrollers – part 1 BJ Furman 29OCT2012.
ARDUINO 1 Under Development. Arduino  Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
ARDUINO 1 Under Development. Arduino  Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi. Objectives 1. Control the rotation of standard servo motor  A standard servo motor is limited in its rotation.
Designing with Components Wilmer Arellano. How to chose a Microcontroller Choose one that you are familiar with or that is easy to learn.
Pulse Width Modulation (PWM). 100% Pulse Width Modulation (PWM) 0% On the chipKIT there are 490 periods per second. Use analogWrite(pin, value) to control.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Code The Arduino Environment.
BM-305 Mikrodenetleyiciler Güz 2015 (3. Sunu) (Yrd. Doç. Dr. Deniz Dal)
ARDUINO 1 By Wilmer Arellano. Arduino.  Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use.
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.
Serial Communication RS-232. In order to make two devices communicate, whether they are desktop computers, microcontrollers, or any other form of integrated.
Microcontroller basics Embedded systems for mortals.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
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?
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
Electronic instrumentation Digitization of Analog Signal in TD
Pulse-Width Modulation: Simulating variable DC output
Written by ZEDO MiniQ - 개요 DFRobot( 에서 MiniQ 2WD 기반에 Romeo V2 All-in-one 컨트롤러 사용하여 사 용자가 다양한 컨스터마이징 작업을 수행할 수 있도록 제공함
Pulse Width Modulation Instructor Dr Matthew Khi 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.
BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)
GPIO Liaison série Entrées analogiques PWM
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Assist. Prof. Rassim Suliyev - SDU 2017
Assist. Prof. Rassim Suliyev - SDU 2017
More on LED’s with Arduino
Wireless Cue Light Project
Arduino Programming Part II
Microcontroller basics
UCD ElecSoc Robotics Club 2017/2018
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Arduino - Introduction
BM-305 Mikrodenetleyiciler Güz 2017 (3. Sunu)
Introduction to Arduinos
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.
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi.
1 Code
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
UNIT 5 Analog signals.
Arduino Uno circuit basics
Setting up a basic program with Arduino
Introduction to Arduinos
Arduino程式範例.
Presentation transcript:

ARDUINO 1

Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We use pin 13 because, * depending on your Arduino board, it has either a built-in LED * or a built-in resistor so that you need only an LED. * * */  // LED connected to digital pin 13

Basics  setup() and loop()  There are two special functions that are a part of every Arduino sketch: setup() and loop(). The setup() is called once, when the sketch starts. It's a good place to do setup tasks like setting pin modes or initializing libraries. The loop() function is called over and over and is heart of most sketches. You need to include both functions in your sketch, even if you don't need them for anything.

 The pinMode() function configures a pin as either an input or an output. To use it, you pass it the number of the pin to configure and the constant INPUT or OUTPUT. When configured as an input, a pin can detect the state of a sensor like a pushbutton. As an output, it can drive an actuator like an LED.  The digitalWrite() functions outputs a value on a pin. For example, the line:  digitalWrite(ledPin, HIGH);  set the ledPin (pin 13) to HIGH, or 5 volts. Writing a LOW to pin connects it to ground, or 0 volts.  The delay() causes the Arduino to wait for the specified number of milliseconds before continuing on to the next line. There are 1000 milliseconds in a second, so the line:  delay(1000);  creates a delay of one second.

Traffic Light Control  Int ledRed = 13; int ledGreen = 11; int ledYellow = 12;  void setup() { pinMode(ledRed, OUTPUT); // sets the digital pin as output pinMode(ledYellow, OUTPUT); // sets the digital pin as output pinMode(ledGreen, OUTPUT); // sets the digital pin as output }  void loop() { digitalWrite(ledGreen, HIGH); // sets the Green LED on delay(1000); // waits for a second digitalWrite(ledGreen, LOW); // sets the Green LED off digitalWrite(ledYellow,HIGH); // sets the Yellow LED on delay(1000); // waits for a second digitalWrite(ledYellow, LOW); // sets the Yellow LED off digitalWrite(ledRed, HIGH); // sets the Red LED on delay(1000); // waits for a second digitalWrite(ledRed, LOW); // sets the Reed LED off }

Ground

Components: TC4421/TC4422

 In the graphic, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of , such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.analogWrite  analogWrite(pin, value)

int right = 13; // Turn Right int left = 12; // Turn Left int forward = 11; // Move forward int reverse = 10; // Move backward void setup() { pinMode(right, OUTPUT); // sets the digital pin as output pinMode(left, OUTPUT); // sets the digital pin as output } void loop() { digitalWrite(left, LOW); digitalWrite(right, HIGH); // Turn Right analogWrite(reverse, 0); delay(500); analogWrite(forward, 200); // Move forward delay(1000); // waits for a second digitalWrite(right, LOW); digitalWrite(left, HIGH); // Turn left analogWrite(forward, 0); delay(500); analogWrite(reverse, 120); // Move backward delay(1000); // waits for a second }

distance = 32/voltage Good for voltage < 2.6 V, distance > 10 cm

Voltage measurement  int analogRead(pin)  Description  Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and This yields a resolution between readings of: 5 volts / 1024 units or,.0049 volts (4.9 mV) per unit. It takes about 100 us ( s) to read an analog input, so the maximum reading rate is about 10,000 times a second.

Setting the baud rate  Serial.begin(int speed)  Description  Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate.

Sending data to computer  Serial.println(data)  Description  Prints a data to the serial port, followed by a carriage return character(ASCII 13, or '\r') and a newline character (ASCII 10, or '\n'). This command takes the same forms as Serial.print():

Sending data to computer  Serial.println(b) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.  Serial.println(b, DEC) prints b as a decimal number in an ASCII string followed by a carriage return and a linefeed.  Serial.println(b, HEX) prints b as a hexadecimal number in an ASCII string followed by a carriage return and a linefeed.  Serial.println(b, OCT) prints b as an octal number in an ASCII string followed by a carriage return and a linefeed.  Serial.println(b, BIN) prints b as a binary number in an ASCII string followed by a carriage return and a linefeed.  Serial.print(b, BYTE) prints b as a single byte followed by a carriage return and a linefeed.  Serial.println(str) if str is a string or an array of chars, prints str an ASCII string.  Serial.println() just prints a carriage return and a linefeed.

 unsigned int voltage1, distance1;  int sensor1 = 0;  void setup()  {  Serial.begin(9600); // setup serial  }  void loop()  {  voltage1 = analogRead(sensor1);  Serial.println(voltage1); // debug value  delay(1000);  }

 int sensor1 = 0;  int forward = 11; // Move forward  int reverse = 10; // Move backward  int stop_f = 286;  unsigned int voltage1 = 0;  void setup()  {  Serial.begin(9600); // setup serial  }  void loop()  {  analogWrite(reverse, 0);  // analogWrite(forward, 0);  Serial.println(voltage1); // debug value  while(voltage1 < stop_f)  {  voltage1 = analogRead(sensor1);  analogWrite(forward, 200); // Move forward  Serial.println(voltage1); // debug value  }  analogWrite(forward, 0); // Move forward  }