Microcontroller basics

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

Electrical team Arduino tutorial I BY: JOSHUA arduini
Lab7: Introduction to Arduino
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.
ELCT 201 week 13 Analog ON/OFF control system conversion to Digital ON/OFF control system.
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.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Embedded Programming and Robotics
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
chipKit Sense Switch & Control LED
Microprocessors Tutorial 1: Arduino Basics
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Cascade switching of an LED EAS 199B Winter 2013.
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Good LED Circuit 5V0 GND. What Voltage Does Meter See? Answer: 5 V.
Microprocessors Tutorial 1: Arduino Basics
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.
Week 5: Microcontrollers & Flow Control Bryan Burlingame 2 March 2016.
Microcontroller basics Embedded systems for mortals.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Hacking on Arduino George Patterson
Introducing the Arduino Uno Presented by Dave Mawdsley, DACS Member, Linux SIG Member (wiring, programming and running a cute traffic light simulation)
Prototyping with Microcontrollers and Sensors. Overview Objective Background Information Problem Statement Materials Procedure Assignment Closing.
Having fun with code, using Arduino in a middle school CS classroom
Arduino.
Arduino Part 1 Topics: Microcontrollers
Assist. Prof. Rassim Suliyev - SDU 2017
Prototyping with Microcontrollers and Sensors
Microcontroller basics
Wireless Cue Light Project
Microprocessors Tutorial 1: Arduino Basics
Microcontroller basics
UTA010 : Engineering Design – II
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
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Introduction to Arduino Microcontrollers
How to avoid catching things on fire.
Week 5: Microcontrollers
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.
Arduino 101 Credit(s):
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno
Welcome to Digital Electronics using the Arduino Board
Introducing the Arduino Uno
CSCI1600: Embedded and Real Time Software
Arduino programs Arduino toolchain Cross-compilation Arduino sketches
Chapter 1 Introduction of Arduino
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
Arduino Part 4 Let there be more light.
CSCI1600: Embedded and Real Time Software
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Lab #1: Getting Started.
Arduino Uno circuit basics
Setting up a basic program with Arduino
SAURABH GINGADE.
Arduino程式範例.
Introduction to Arduino IDE and Software
Interrupts.
Presentation transcript:

Microcontroller basics Embedded systems for mortals

Lesson 1 Working with Arduino IDE Basic electric components Your first program Digital input and output

Arduino IDE Download from: http://arduino.cc/en/Main/Software Version 1.0.6 or newer

About Arduino Uno 14 Digital I/O pins (6 PWM) Reset button USB port 12 V input Get its name Uno, meaning one in Italian, because it was first released at the same time as Arduino IDE version 1.0 Pin 13 is also assigned to the intregrated LED GND is ground, 5 Volt is and 5 volt output 6 Analog Input pins 3.3 V and 5 V outputs

Setting up Arduino IDE Remeber to all check that the port is correct! (COM4 for example)

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

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, INPUT_PULLUP, 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). IMPORTANT TO NOTICE: Depending whether the pin is set as an OUTPUT or INPUT the actual effect of digitalWrite() is different INPUT_PULLUP uses an internal pullup resistor: Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal  20K-ohm resistor is pulled to 5V. This configuration causes the input to  read HIGH when the switch is open, and LOW when it is closed. Explain about the need of a pull-up or pull-down resistor

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 (=0,1s) digitalWrite(ledPin, LOW); //LED OFF delay(1000); //Wait 1000ms (=1s)

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

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.

Basic Components Passive components Active components Resistor LED Capacitor Transistor Push button Integrated circuit (IC) IC contains a lot of transistors. Inductor

Example 2 – Push Button Reading digital input

Example 2 - Code Reading digital input (Using push button) byte ledPin = 13; byte buttonPin = 2; void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); //set ledPin off as default pinMode(buttonPin, INPUT); //set buttonPin as input digitalWrite(buttonPin, HIGH); //set the default state of the pin to HIGH (+5V) } void loop() if(digitalRead(buttonPin) == LOW) digitalWrite(ledPin, HIGH); //LED ON else digitalWrite(ledPin, LOW); //LED OFF

Microcontrollers typically operate on low voltages (0-5V) →You must be careful when connecting devices Know the electrical limits of the microcontroller: Uno can handle max 5V/40mA per pin Always double check the wiring! If you see smoke it’s already too late!

P=U*I M U=R*I To prevent overloading a pin or a component with excessive current you need to use a resistor Example: Using an LED – Calculating the required resistor size Operation voltage for LED: 5V Recommended current 23mA 𝑈=𝑅∗𝐼→𝑅= 𝑈 𝐼 = 5𝑉 0,023𝐴 ≈220Ω Ask the class, wha is calculated?

Check resistor power-rating Check resistor power-rating! These resistors are meant for signal processing (max.25 W)

Example 3 – adding a LED Longer pin

Analog input Timers Interrupts In next lesson Analog input Timers Interrupts