Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Lab7: Introduction to Arduino
ARDUINO FRAMEWORK.
Mini-SumoBot Construction and Programming
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Intro to the Arduino Topics: The Arduino Digital IO Analog IO Serial Communication.
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.
1 Arduino Board: Arduino UNO Arduino Programing Environment: Arduino 0022
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Intel Do-It-Yourself Challenge Hello World with the Arduino IDE Nicolas Vailliet Intel.
Parallax 4x20 LCD (part number 27979) with Arduino Duemilanove
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Arduino Part 1 Topics: Microcontrollers Programming Basics: structure and variables Digital Output Analog to Digital Conversion.
Week 10 Today 1.Homework presentations and critique. 2.Review digital and analog inputs. 3.DIY - jumpers, soldering etc.
DPNM Lab., POSTECH 1/25 CS490K - Internet of Things (IoT) Jonghwan Hyun DPNM Lab. Department of Computer Science and Engineering, POSTECH
Intro to the Arduino Topics: The Arduino Digital IO
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.
Introduction to the Arduino
Intro to Arduino Programming. Draw your circuits before you build them From Arduino 330 Ohm From Arduino 330 Ohm From Arduino 330 Ohm.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Code The Arduino Environment.
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Arduino libraries Datatekniker Udvidet hardware/software.
Basic Circuits – Lab 5 Wireless Networking Xmedia Spring 2011.
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.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
Welcome to Processing Who does not have access to digital camera?
Serial Communication RS-232. In order to make two devices communicate, whether they are desktop computers, microcontrollers, or any other form of integrated.
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?
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Arduino Programming. THE ARDUINO IS A MICROCONTROLLER – A LOW COST, LOW PERFORMANCE COMPUTER.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Arduino.
Arduino Part 1 Topics: Microcontrollers
Lab 7 Basic 1: Game of Memory
Application of Programming: Scratch & Arduino
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Assist. Prof. Rassim Suliyev - SDU 2017
Assist. Prof. Rassim Suliyev - SDU 2017
Introduction to the Arduino
Arduino & its hardware interfacing
Arduino Programming Part II
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
European Robotic LABoratory
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
CU ATLAS Practical electronics MIDI and Arduino
Arduino Uno and sensors
Introduction to Arduino Microcontrollers
Topics: Analog/Digital Read Relay control 7 segment control Buzzer
Roller Coaster Design Project
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Intro to the Arduino Topics: The Arduino Digital IO
using for loops to control LEDs
1 Code
Topics: Programming Constructs: loops & conditionals Digital Input
Programming 2: The Arduino IDE & First Sketches
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Lab #1: Getting Started.
Arduino Uno circuit basics
Introduction to arduino
Introduction to Arduino IDE and Software
Presentation transcript:

Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input

Serial Communication todbot.com/blog/bionicarduino

Serial Communication Compiling turns your program into binary data (ones and zeros) Uploading sends the bits through USB cable to the Arduino The two LEDs near the USB connector blink when data is transmitted RX blinks when the Arduino is receiving data TX blinks when the Arduino is transmitting data todbot.com/blog/bionicarduino

First Program /* * Hello World! * From * It shows how to send data to the computer */ void setup() // run once, when the sketch starts { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Hello world!"); // prints hello with a line break } void loop() // run over and over again { // do nothing! }

Open the Serial Monitor and Upload the Program

Modify the Program (each bullet is a different mod) Move Serial.println("Hello world!"); to loop() Add the following to setup(): int a = 5; int b = 10; Serial.print("a + b = "); Serial.println(a + b); Replace the code above with the following:

Conditional Statement if (someCondition) { // do stuff if the condition is true } else { // do stuff if the condition is false } modelect.wordpress.com

Conditional Statement int printMessage = 1; void setup() { Serial.begin(9600); } void loop() { if (printMessage == 1) { Serial.println("Message"); printMessage= 0; } int printMessage = 1; void setup() { Serial.begin(9600); } void loop() { if (printMessage == 1) { Serial.println("Message"); printMessage= 0; } else { Serial.println("NO Message"); printMessage= 1; }

while Loop while(expression){ statement(s); } Example int var = 0; while (var < 200) { // do something repetitive 200 times var = var + 1; }

while Loop void setup() { Serial.begin(9600); int count = 0; while (count < 5) { Serial.println("Hello world!"); count = count +1; } void loop() { }

for loop martin-thoma.com

for Loop void setup() { Serial.begin(9600); for (int count = 0; count < 5; count++) { Serial.println("Hello world!"); } void loop() { }

Functions loop() and setup() are procedures You can create you own functions arduino.cc void setup() { } void loop() { } Both setup() and loop() have no parameters and return no values

Functions: Example 1 learn.parallax.com

Functions: Example 2 learn.parallax.com

Digital Input (introducing the switch) Create the circuit above and then run File -> Examples -> Digital -> Button push-button switch