European Robotic LABoratory

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

EMS1EP Lecture 6 Digital Inputs
ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Lab7: Introduction to Arduino
ARDUINO FRAMEWORK.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Embedded Sumo 1T4 – 1T5 UTRA.
Gary Sutcliffe, W9XT Copyright © 2012 Gary C. Sutcliffe.
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
Digital & Analog Inputs. Review Fundamental parts of an Arduino program are … Setting output types using pinMode. Declaring variables Can write a digital.
Photo-sensor Digital Camera Na 556 Transistor 2N-3904.
Living with the lab Introduction to Arduino Programming arduino.cc Gerald Recktenwald Portland State University
Finish your programs from last week STOPLIGHT CIRCUIT! You may need … – int – void setup() – void loop() – pinMode – digitalWrite – delay.
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.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2011 LWTL faculty team.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.
chipKit Sense Switch & Control LED
Switches & whiskers on the Arduino living with the lab lever arm switches mounted to Arduino © 2012 David Hall.
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Cascade switching of an LED EAS 199B Winter 2013.
Wall Encounter By Made easy by Dwayne Abuel.
LECTURE 2 – INPUTS THIS LECTURE WILL INTRODUCE HOW TO INPUT SIGNALS INTO AN ARDUINO.
Code The Arduino Environment.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Programming, Serial and Virtual Prototyping. Code if ( You like semicolons ) { Stay here for intro to Arduino code } else { Join the MODKit group for.
Arduino libraries Datatekniker Udvidet hardware/software.
IR Object Detection living with the lab IR light from LED IR light reflected off object IR LED IR receiver Infrared (IR) light leaving an LED reflects.
Robotics Grant Agreement No LLP UK-LEONARDO-LMP Project acronym: CLEM Project title: Cloud services for E-Learning in Mechatronics Technology.
LAB1 TYWU. Devices Dip Switch (4 Switches) Triple Output LED (RGB) –Common Cathode.
:Blink Blink: Er. Sahil Khanna
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin 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.
physical computing .2 – Day 3
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
European Robotic LABoratory
Assist. Prof. Rassim Suliyev - SDU 2017
More on LED’s with Arduino
Val Manes Department of Math & Computer Science
UTA010 : Engineering Design – II
Cascade switching of an LED
UCD ElecSoc Robotics Club 2017/2018
INC 161 , CPE 100 Computer Programming
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Lecture 2-2: Arduino Programming
Arduino.
Въведение в Arduino.
Introduction to Arduinos
Topics: Analog/Digital Read Relay control 7 segment control Buzzer
Programming, Serial and Virtual Prototyping
1 Code
Using Photoresistors with an Arduino
CS-4540 Robotics - Lab 05 Switch inputs to the Arduino Uno
Implementing Switches Using Interrupts
Arduino: For Loops.
Arduino programs Arduino toolchain Cross-compilation Arduino sketches
Arduino : Introduction & Programming
LED LIGHT USING SOUND SENSOR & LIGHT SENSOR
Programming 2: The Arduino IDE & First Sketches
Decision making and control functions
Arduino Uno circuit basics
Setting up a basic program with Arduino
Introduction to Arduinos
SAURABH GINGADE.
Arduino程式範例.
Arduino UMBC IEEE Sekar Kulandaivel Week 3: Motor Control w/ H-Bridges
Introduction to Arduino IDE and Software
Presentation transcript:

European Robotic LABoratory EURLAB European Robotic LABoratory Basic knowledge x.x: How to decide with Arduino EURLAB Basic knowledge x.x – How to decide with Arduino

How to decide with Arduino of course, when you want to solve a problem by a program for Arduino, you must have the ability to implement a decision. This is possible by mean the 'IF‘ statement. EURLAB Basic knowledge x.x - How to decide with Arduino

The ‘IF’ statement ………………….. if (‘condition’) { // here you can put First possibility: to do or not an ‘action’. In this case, when condition is ‘false’ nothing is done! ………………….. if (‘condition’) { // here you can put // statements // to realize if // condition is // true } …………………… Example: int buttonState = 0; // variable for reading the button 4 status void setup() { pinMode(13, OUTPUT); // initialize the LED pin 13 as an output: pinMode(4, INPUT); // initialize the pin 4 as an input: } void loop() { buttonState = digitalRead(4); // read the state of the button 4 // check if the pushbutton is pressed. if (buttonState == HIGH) { // if it is pressed…… digitalWrite(13, HIGH); // ……turn LED on: } EURLAB Basic knowledge x.x - How to decide with Arduino

// if condition is false The ‘IF’ statement Second possibility: Do ‘action 1’ if condition ‘true’. Do ‘action 2’ if condition ‘false’ if (‘condition’) { // here you can put // statements // if condition is true } else // if condition is false Example: int buttonState = 0; // variable for reading the button 4 status void setup() { pinMode(13, OUTPUT); // initialize the LED pin 13 as an output: pinMode(4, INPUT); // initialize the pin 4 as an input: } void loop() { buttonState = digitalRead(4); // read the state of the button 4 // check if the pushbutton is pressed. if (buttonState == HIGH) { // if it is true…… digitalWrite(13, HIGH); // ……turn LED on: } else digitalWrite(13, LOW); // ……turn LED off: EURLAB Basic knowledge x.x - How to decide with Arduino

The ‘SWITCH-CASE’ statement Sometimes you have to choose between more than two situations: In this situation is useful to use the ‘SWITCH-CASE’ instuctions EURLAB Basic knowledge x.x - How to decide with Arduino

The ‘SWITCH-CASE’ statement Example: int sensorValue = 0; // variable to store the value coming from the sensor void setup() { pinMode(13, OUTPUT); // set Pin 13 as an OUTPUT pinMode(12, OUTPUT); // set Pin 12 as an OUTPUT } void loop() { sensorValue = analogRead(A0); // read the value from sensor attached to input A0: switch (sensorValue) { case 50: digitalWrite(13,LOW); digitalWrite(12,LOW); break; // exit from ‘case’ structure without evaluating other cases case 100: digitalWrite(13,HIGH); digitalWrite(12,LOW); case 150: digitalWrite(13,LOW); digitalWrite(12,HIGH); case 200: digitalWrite(13,HIGH); digitalWrite(12,HIGH);} } EURLAB Basic knowledge x.x - How to decide with Arduino