Beginning Arduino Session 2 AN INTRODUCTION TO HACKING THE WORLD’S MOST POPULAR MICROCONTROLLER PLATFORM

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 6 Digital Inputs
Advertisements

EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Electrical team Arduino tutorial I BY: JOSHUA arduini
Lecture 1 – Arduino Basics
Lab7: Introduction to Arduino
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
Intro to the Arduino Topics: The Arduino Digital IO Analog IO Serial Communication.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
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
Introduction.
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.
Embedded Programming and Robotics
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.
Image of Arduino. Arduino discussion Address issues with circuit walk-through – Electricity, Programming, Arduino Concepts Work on BeatTable (next week)
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
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
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.
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:
SAMI MAKERSPACE MAKE: AN ELECTRONICS WORKSHOP. ARDUINO BASICS Credit to: Sparkfun and Linz Craig, Nick Poole, Prashanta Aryal, Theo Simpson, Tai Johnson,
Microcontrollers, Microcomputers, and Microprocessors
Arduino libraries Datatekniker Udvidet hardware/software.
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.
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.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Bdps 2 Lecture 2. Circuits and Ohm's Law For resistive circuits.
Introduction to Arduino A very basic intro to Arduino, the IDE and the Servos class.
:Blink Blink: Er. Sahil Khanna
Arduino “Getting Started” Instructor : Dr Matthew Miss Khin Yi Kyaw
Pulse-Width Modulation: Simulating variable DC output
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
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.
Having fun with code, using Arduino in a middle school CS classroom
Welcome to Arduino A Microcontroller.
Microcontroller basics
Microcontroller basics
Sound Effects with Arduino
Microprocessors Tutorial 1: Arduino Basics
Arduino & its hardware interfacing
UTA010 : Engineering Design – II
An Arduino Workshop A Microcontroller.
UCD ElecSoc Robotics Club 2017/2018
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Introduction to Arduino Microcontrollers
Introduction to Arduino Microcontrollers
Introduction to Arduinos
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.
What is an Arduino ? Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Continuing with LED’s and Arduino
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
IoT Programming the Particle Photon.
Arduino 101 Credit(s):
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Implementing Switches Using Interrupts
Arduino programs Arduino toolchain Cross-compilation Arduino sketches
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
Introduction to Arduinos
Interrupts.
Presentation transcript:

Beginning Arduino Session 2 AN INTRODUCTION TO HACKING THE WORLD’S MOST POPULAR MICROCONTROLLER PLATFORM

2.0 – Welcome and Introduction 2.1 – Components used in this Project. 2.2 – Exploring a Switch and its effects in a digital system. 2.3 – De-bouncing a switch – Blink Without Delay ­­­­­ ­ ­ 2.4 – Exploring the 4 main uses for a resistor – Current Limiting – Voltage Division – Pull Down – Pull Up Today’s Agenda

2.5 – Exploring Speakers and Piezo Buzzers – How a speaker works vs a Piezospeaker 2.6 – PWM outputs, what are they? A detailed look into Pulse width Modulation 2.7 – The RGB LED 2.8 – Exploring Libraries. 2.9 – Using Tabs, creating our own Lib 2.10 – Using integer Arrays 2.11 – Bringing it all together: Name That Tune 2.12 – Serial Feedback Shields Today’s Agenda (cont.)

TAC Switch x 4 Peizo Buzzer x 1 RGB Breakout x 1 Components used in this Project.

Circuit:

When a switch is pressed in a circuit it casues the line voltage to “bounce” Bouncing

Sample of a switch press

When timing is crucial or multiple things need to happen during the void loop(), the delay() command can become a big problem. Open example > Basic > Blink Blink

void setup() { pinMode(13,OUTPUT); pinMode(9,OUTPUT); pinMode(2,INPUT); } Modify the Blink Sketch setup

void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second if(digitalRead(2) == LOW) digitalWrite(9,HIGH); else digitalWrite(9,LOW); } Modify the Blink Sketch loop

Open sketch examples > Digital > Blink without delay Blink Without delay()

Modify the sketch in the same way, what happens differently? Modify the sketch

Current Limiting Voltage Division Pull Down Pull Up Four Main uses for a Resistor

Current Limiting Resistor

Voltage Divider

Pull-UP

void setup() { pinMode(6,OUTPUT); } void loop() { if(digitalRead(2) == LOW) digitalWrite(6,HIGH); else digitalWrite(6,LOW); } Example of INPUT_PULLUP

The Piezo Buzzer

Pulse Width Modulation Is a DC voltage that is turned ON and OFF at different rates. The voltage has 2 states, 0 and Vcc PWM

A Low pass Filter will smooth a PWM signal back to a DC voltage. Low Pass Filter

Single Color Bi-Color Tri-Color RGB Types of LEDs

The RGB LED provided in your kit is mounted on a Breakout board. A breakout board provides all the nessesary supporting electronics so it can be used easily and quickly for proto typeing. The RGB LED with your Kit

void setup() { pinMode(6,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); } void loop() { digitalWrite(9,HIGH); delay(300); digitalWrite(9,LOW); digitalWrite(10,HIGH); delay(300); digitalWrite(10,LOW); digitalWrite(6,HIGH); delay(300); digitalWrite(6,LOW); } RGB LED test

Libraries are chunks of code writen for specific, and often repetitive task. # include or # include “Lib_Name” Libraries

Go to – Download the IRremote.zip file Download and install Libraries.

Method 1 Automatic – Go to Sketch > Input Library > Add Library. Navigate to the file just downloaded and select it. Method 2 Manually extract the Library and copy the folder to the Lib folder within the Arduino sketch folder. Two ways to install a Library

// Our Lib of Pitches #define NOTE_G1 49 #define NOTE_B2 123 #define NOTE_F3 175 #define NOTE_G4 392 Create a Library

An array is a collection of variables that are accessed with an index number. Arrays are Zero indexed. Arrays

// Call my Lib #include "pitches.h" // Define my Array int BP[] = {NOTE_G4, NOTE_B2, NOTE_F3, NOTE_G1}; Bringing it all together

// Declare my variabls int INDEX = 2; // Start button int redLEDPin = 9; int greenLEDPin = 10; int blueLEDPin = 6; Bringing it all together

// Set my pin modes void setup() { pinMode(2,INPUT_PULLUP); pinMode(3,INPUT_PULLUP); pinMode(4,INPUT_PULLUP); pinMode(5,INPUT_PULLUP); pinMode(13,OUTPUT); pinMode(redLEDPin,OUTPUT); pinMode(greenLEDPin,OUTPUT); pinMode(blueLEDPin,OUTPUT); } Bringing it all together

// My loop void loop() { if(digitalRead(INDEX) == LOW) { tone(8,BP[INDEX-2]); RGBWrite(random(100),random(100),random(100)) ; while(digitalRead(INDEX) == LOW) { } RGBWrite(0,0,0); noTone(8); } INDEX=INDEX+1; if(INDEX > 5) INDEX = 2; } Bringing it all together

Press keys in this order 1 – 2 – 3 – 4 – 2 Name that tune

There is 1 UART (universal asynchronous receiver/transmitter) on the Arduino Uno The Serial port uses Pin 0 and 1 Pin 0 = RX or Data Receive Pin 1 = TX or Data Transmit The USB connection uses the same UART Serial Feedback

int R = random(100); int G = random(100); int B = random(100); if(digitalRead(INDEX) == LOW) { Serial.print(INDEX); Serial.print("|"); Serial.print(R); Serial.print("|"); Serial.print(G); Serial.print("|"); Serial.println(B); // Serial.println() adds a line feed to the end tone(8,BP[INDEX-2]); RGBWrite(R,G,B) ; Add to the script

A Shield is a supportive board that plugs into the Arduino to extend the Arduino’s ability and reduces the amount of bread boarding needed. There’s a Shield for that…

Shields

Challenge #1 – Use a switch-case and make specific colors light up based on the tone being played. Challenge #2 – Team up and use 8 buttons to make a 8 Key Keyboard Challenge #3 Use the Ir Lib to play sounds from your Remote. Challenge