Microcontroller basics

Slides:



Advertisements
Similar presentations
Electrical team Arduino tutorial I BY: JOSHUA arduini
Advertisements

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.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
ELCT 201 week 13 Analog ON/OFF control system conversion to Digital ON/OFF control system.
Living with the Lab Using servos with an Arduino EAS 199A Fall 2011.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
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.
Microprocessors Tutorial 1: Arduino Basics
Arduino Circuits and Code. int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, LOW); delay(1000); digitalWrite(ledPin,
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Arduino Training New Mexico Mathematics, Engineering, and Science Achievement (NM MESA) Getting Started.
Rebecca Bruce and Susan Reiser, May 2015 Analog Input and Output.
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.
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.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
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?
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
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).
Intro to Arduino Basic Arduino John Wolf (WolfDenElectronics.com)
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Pulse-Width Modulation: Simulating variable DC output
Microcontroller basics Embedded systems for mortals.
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.
Introducing the Arduino Uno Presented by Dave Mawdsley, DACS Member, Linux SIG Member (wiring, programming and running a cute traffic light simulation)
Having fun with code, using Arduino in a middle school CS classroom
Microcontroller basics
Assist. Prof. Rassim Suliyev - SDU 2017
CU ATLAS Practical electronics Motion and Servos
If you want to swing an robot arm or …
Week 6: Style and Peripherals
Microcontroller basics
Wireless Cue Light Project
Microcontroller basics
UTA010 : Engineering Design – II
Program the robotic arm
Get Your Project Started with Arduino
Get Your Project Started with Arduino
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
Arduino Part 1 Topics: Microcontrollers Programming Basics
Въведение в Arduino.
Arduino - Introduction
Control the color and brightness of an RGB LED with a Potentiometer
Control a motors angular position with a flex sensor
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Roller Coaster Design Project
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.
IoT Programming the Particle Photon.
Introducing the Arduino Uno
Arduino : Introduction & Programming
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
UNIT 11: RC-SERVOMOTOR CONTROL
Lab #1: Getting Started.
Setting up a basic program with Arduino
Introduction to Arduinos
Arduino程式範例.
Introduction to Arduino IDE and Software
Interrupts.
Pulse-Width Modulation: Simulating variable DC output
Presentation transcript:

Microcontroller basics

Arduino IDE Download from: http://arduino.cc/en/Main/Software

About Arduino Uno 14 Digital I/O pins (6 PWM) Reset button USB port 12 V input 6 Analog Input pins 3.3 V and 5 V outputs http://www.farnell.com/datasheets/1682209.pdf

Setting up Arduino IDE

Structure of an Arduino code 1. Define Variables Before going to the setup function constant variables should be defined int pin = 1; 2. Setting up functions void setup() {} Setup function is run once, when the microcontroller boots up or resets. After setup function the processor moves to run code inside the loop function. Code inside loop function will be run over and over until the microcontroller is shut down. void loop() {} 3. Eternal loop It’s required to have both setup() and loop() functions in the code

Example 1 - Blinking led You need Breadboard Led Resistor (270 ohm) Arduino Wires

Breadboard Terminals with blue and red lines are called power busses and are connected together horizontally. Terminals in the middle are connected together vertically. The gap in the middle separates the two sides.

Example 1 http://blog.grifby.com/2013/04/tutorial-1-blinking-led-using-arduino.html

Arduino C – Basic functions pinMode(var1, var2) pinMode functions sets the mode of given pin. Var1 is the number of the pin and var2 is the mode (INPUT, OUTPUT) digitalWrite(var1, var2) digitalWrite changes the status of the pin. Var1 is the number of the pin and var2 is the status (LOW, HIGH).

Writing your first program Basic blinking LED int ledPin = 13; void setup() { pinMode(ledPin, OUTPUT); } void loop() digitalWrite(ledPin, HIGH); delay(1000); digitalWrite(ledPin, LOW);

Writing your first program Basic blinking LED int ledPin = 13; //Variable to store the pin number void setup() { pinMode(ledPin, OUTPUT); //set ledPin as output } void loop() digitalWrite(ledPin, HIGH); //LED ON delay(1000); //Wait 1000ms (=1s) digitalWrite(ledPin, LOW); //LED OFF

Uploading the program Click Verify The program is checked Click Upload The program is uploaded to the Arduino mCu board 2. 1.

Example 2 - Controlling servomotor with Arduino Servomotor is controlled with PWM signal For controlling servomotor only Arduino is needed Arduino IDE has its own servomotor library

PWM (Pulse Width Modulation) Basic terms Duty cycle = Pulse Width / Wave Period

Example 2 Using 5 V servo motor

Example 2 #include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9); } void loop() for(pos = 0; pos <= 120; pos += 1) myservo.write(pos); delay(15); for(pos = 120; pos>=0; pos-=1)

Example 2 #include <Servo.h> Servo myservo; // create servo object to control a servo int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() for(pos = 0; pos <= 120; pos += 1) // goes from 0 degrees to 120 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position for(pos = 120; pos>=0; pos-=1) // goes from 120 degrees to 0 degrees

Example 3 - Servomotor control with potentiometer You need Breadboard Servomotor Potentiometer Arduino Uno Wires

Example 3 http://www.electroschematics.com/11453/digital-potentiometer-arduino-shield/

Example 3 analogRead(analogPinNumber); Reads the analog pin where the potentiometer is attached map(value, fromLow, fromHigh, toLow, toHigh); Scales the potentiometer value to servomotors angle The analog input has 10 bit resolutions

Example 3 #include <Servo.h> Servo myservo; // create servo object to control a servo int potpin = A0; // analog pin used to connect the potentiometer (F0/A0) int val; // variable to read the value from the analog pin void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 120); // scale it to use it with the servo (value between 0 and 120) myservo.write(val); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there