Arduino Programming. THE ARDUINO IS A MICROCONTROLLER – A LOW COST, LOW PERFORMANCE COMPUTER.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

ARDUINO CLUB What we’re really doing. BASICS The setup() and loop() functions.
Lab7: Introduction to Arduino
Intermediate Electronics and Lilypad Where Electronics Meet Textiles Workshop with Lynne Bruning and Troy Robert Nachtigall Sponsored by Spark Fun and.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Embedded Sumo 1T4 – 1T5 UTRA.
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
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.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
Arduino Part 2 Topics: Serial Communication Programming Constructs: functions, loops and conditionals Digital Input.
FUN WITH COOL KIT. Kit Purpose Have fun assembling and programming a simple robot – Includes chassis, wheels, motors, motor driver, IR sensor and arduino.
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
Intro to Arduino Programming. Draw your circuits before you build them From Arduino 330 Ohm From Arduino 330 Ohm From Arduino 330 Ohm.
1 of 20 Core Arduino Workshop Chris Koehler and Brian Sanders Colorado Space Grant Consortium.
Tweaking Your Simon Adding a photoresistor and changing code Instruction by Pete Lewis and Linz Craig.
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
Code The Arduino Environment.
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.
1 - Remove LED from 13 and GND - Bring out your breadboard from HW#4 Arduino Overview:
Microcontrollers, Microcomputers, and Microprocessors
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.
C# SERIAL COMMUNICATION TEMPERATURE CONTROL WITH ARDUINO KAAN EREN
ME 120: User-defined functions: average analog input reading Arduino Programming – Part 5: User-defined functions ME 120 Mechanical and Materials Engineering.
Microcontroller basics Embedded systems for mortals.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Introduction to Programming the Arduino Dr Gaw 3/21/14.
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Electronic instrumentation Digitization of Analog Signal in TD
ME 120: Photoresistors and Arduino Programming Arduino Programming Case Study: Photoresistor Measurements ME 120 Mechanical and Materials Engineering Portland.
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.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Having fun with code, using Arduino in a middle school CS classroom
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Assist. Prof. Rassim Suliyev - SDU 2017
Val Manes Department of Math & Computer Science
Arduino & its hardware interfacing
Microcontroller basics
UTA010 : Engineering Design – II
Welcome to Arduino A Microcontroller.
Get Your Project Started with Arduino
UCD ElecSoc Robotics Club 2017/2018
INC 161 , CPE 100 Computer Programming
Въведение в Arduino.
Arduino - Introduction
Arduino Uno and sensors
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Analog Input through POT
Arduino and Grove LET’S START.
Introduction to Arduinos
Roller Coaster Design Project
Arduino 101 Credit(s):
1 Code
Using Photoresistors with an Arduino
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Welcome to Digital Electronics using the Arduino Board
Topics: Programming Constructs: loops & conditionals Digital Input
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Aeroponic Engineering and Vertical Farming
Arduino Uno circuit basics
Introduction to Arduino IDE and Software
CTY SAR FCPS Alexander Velikanov
Presentation transcript:

Arduino Programming

THE ARDUINO IS A MICROCONTROLLER – A LOW COST, LOW PERFORMANCE COMPUTER

MICROCONTROLLERS DO SIMPLE THINGS WELL

Basic sensing and response

LOW POWER

How much power does your laptop need?

Most microcontrollers are capable of going into a sleep mode where they draw very little power

ARDUINO PROGRAMMING

Before you begin, go to tools, and make sure the board is set to Uno, and the Serial Port is set to the highest number

Make sure you can upload the code blink from examples/basic. If it worked, there should be a light slowly blinking on your Arduino

Every code your write needs to have two sections, void setup and void loop, but they can be empty

BASIC VARIABLES AND MATH

The serial monitor lets you print values from your code. It is going to be your best friend when it comes to debugging your code Click here

You will (hopefully not) make this mistake! The serial lines are connected to digital pins 0 and 1 on the Arduino. You usually don’t want to connect anything else to these lines.

You can use variables to store numbers, but you might get funny results int a = 6; int b = 2; void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.print("a divided by b is: "); Serial.println(a/b); Serial.print("b divided by a is: "); Serial.println(b/a); } void loop() { // put your main code here, to run repeatedly: } float a = 6; float b = 2; void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.print("a divided by b is: "); Serial.println(a/b); Serial.print("b divided by a is: "); Serial.println(b/a); } void loop() { // put your main code here, to run repeatedly: }

My advice would be to use floats for all of your variables until you get better at figuring out how these work.

CONTROLLING YOUR CODE

If statements can be use to make basic decisions in your code Syntax if(conditional statement) { Your code goes here } Example if(testVal == number) if(testVal < number) if(testVal > number1 && testVal < number2 )

Else if and else Syntax if(conditional statement) { } else if(conditional statement) { } else { }

Anatomy of a for loop in Arduino Example: for(int i = 0; i<10 ; i++) { Serial.println(i); } The variable i here is our counter You need to declare the variable with “int” This section says to run the loop while the counter i is less than 10 This section says to add 1 to our counter each time through the for loop Serial monitor output This code will now run 10 times

You can read a sensor with the analogRead() function (see the example in basic/analogReadSerial). The Arduino gives each voltage between 0 and 5 volts a number between 0 and How could we convert from the number we get to a real voltage?

Use the LM35 temperature sensor to measure temperature. The voltage goes up 10 mV for each degree C. Print the temperature to the serial monitor.