ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.

Slides:



Advertisements
Similar presentations
Wireless Cue Light Project
Advertisements

Book Project Sue Brandt Arduino Project Interactive with LEDS.
Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
EMS1EP Lecture 6 Digital Inputs
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Electrical team Arduino tutorial I BY: JOSHUA arduini
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.
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.
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2012 David Hall.
Using the Arduino to Make an LED Flash Work in teams of two! living with the lab digital I/O pins (I/O = input / output) USB cable plug power pins.
Living with the Lab Using Your Arduino, Breadboard and Multimeter EAS 199A Fall 2011 Work in teams of two!
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.
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.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
chipKit Sense Switch & Control LED
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.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Good LED Circuit 5V0 GND. What Voltage Does Meter See? Answer: 5 V.
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.
Microcontroller Hands-on Workshop #2 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers October 31, 2009.
Arduino libraries Datatekniker Udvidet hardware/software.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
Microcontroller basics Embedded systems for mortals.
Week 5: Microcontrollers & Flow Control Bryan Burlingame 2 March 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?
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
Arduino Training For You! Learn Programming at Your Own Pace! Chapter 1 A course developed from the text book: “Introduction to Arduino A Piece of Cake!”
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
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.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Microcontroller basics
Microcontroller basics
UTA010 : Engineering Design – II
Welcome to Arduino A Microcontroller.
European Robotic LABoratory
UCD ElecSoc Robotics Club 2017/2018
INC 161 , CPE 100 Computer Programming
Arduino.
Introduction to Arduino 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.
using the Arduino to make LEDs flash
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
analog and digital measurements
Arduino : Introduction & Programming
Arduino Part 4 Let there be more light.
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino Motor Lab Inspired by NYU ITP project
CTY SAR FCPS Shawn Lupoli, Elliot Tan
I/O Programming with Arduino
Aeroponic Engineering and Vertical Farming
Arduino Uno circuit basics
Setting up a basic program with Arduino
SAURABH GINGADE.
UNIT 1 First programs.
Arduino程式範例.
Introduction to Arduino IDE and Software
Interrupts.
Presentation transcript:

ARDUINO CLUB What we’re really doing

BASICS The setup() and loop() functions

void setup() Like the main() you’re used to For setting pin modes pinMode(pinNumber,MODE); MODE can be ‘INPUT’ or ‘OUTPUT’ pinNumber is the number of the pin Useful to start serial connection here Serial.begin(9600); Only run once, when the arduino board powers on

void loop() Also like main() This is where you put your actual program This loops until the board loses power, or breaks

CONTROLLING PINS But I want to make my LED flash! D:

digitalWrite() Basically, turns things on and off digitalWrite(pinNumber,STATE); pinNumber can be any pin that was set, in the the setup, to be an output STATE can either be ‘HIGH’ or ‘LOW’ (on or off)

digitalRead() Checks if inputs are high, or low digitalRead(pinNumber) pinNumber can be any pin that you set as an INPUT in the setup loop Will return either HIGH or LOW

delay() Pauses the program for a set amount of time delay(time); Time is in milliseconds, so 1 second would be delay(1000)

WIRING Make sure you don’t blow things up

LEDs Require 220Ω resistor (red, red, brown)

CONDITIONALS

"If" Statements These allow us to perform an action, if a condition is met, and otherwise perform another action #include int i; void main(){ printf("Enter a number! \n"); scanf("%d",&i); if (i == 0){ printf("that number was zero \n"); } else { printf("that number was not zero \n"); }

Logic Operators == means equal to != means not equal to && means AND || means OR > means greater than < means less than >= means greater than or equal to <= means less than or equal to

Buttons Need to be connected to ground as well as +volts

LOOPS

"While" Loops These allow us to loop code indefinitely until a condition is met: #include //You get the point int x = 0; //Declares x variable void main(){ //Starts main while(x<100){ //Starts while loop with condition x++; //Increases x by one printf("%d \n",x); //Prints value of x }

"For" Loops Used for performing actions a set amount of times Also useful for looping through an ARRAY Started by: "for (initialization, condition, increment) {(functions in here)}" Initialization is run only once, and is usually decleration of the condition variable Condition decides when the for loop will stop, once it is false the loop will be exited The increment decides how the condition variable will be increased/decreased #include /* includes stdio library, necessary */ void main(){ // starts main function for (int x = 0; x<100; x++){ // sets how the for loop will run printf("%d \n", x); /* prints "x" until it"s equal to 100, then stops */ }

"For" Loops with Arrays We can also iterate through an array with a for loop, as shown below: #include //Necessary int myNum[2]={1,3}; //Defines array int arraySize=sizeof(myNum)/sizeof(int); //Works out length of the array int i=0; //Defines i for iterating void main(){ //Starts main for(i=0;i<arraySize;i++){ //Starts for loop printf("%d \n",myNum[i]); //Outputs each field }

A Note about Iterating Iterators usually take the form of: Variable++ This will increase "Variable" by one every iteration Variable-- This will decrease "Variable" by one every iteration We aren’t limited to this, an iterator can have any mathematic function applied to it, however these are the most common