SlideShare a Scribd company logo
1 of 51
Arduino
Gowtham Thamilarasu
Senior Embedded Design Engineer
Sparks Automations
TOP LEVEL MANAGEMENT
HUMAN RESOURCE
MANAGEMENT
PROJECT MANAGER
TEAM LEADER
TEAM MEMBERS
PLANNING DESIGNING H/W
ASSEMBLY
TESTING
S/W
DEVELOP
MENT
INTEGRATI
ON
PRODUCT
#include<stdio.h>
Void main()
{
portd=0x00;
while(1)
portd=oxff;
}
• What is a microcontroller and a
microprocessor?
• Difference between microprocessor &
microcontroller?
• Evolution of Embedded in day-to-day life
• Types of Architecture
• Types of Processors
• Program Memory and Data Memory
• Hard Disk is RAM or ROM?
• Compiler Vs Cross Compiler
• Pipeline
• Application
• Arduino Microcontroller
FLAG
REGISTER
ALU
PROGRAM
COUNTER
INSTRUCTION
REGISTER
INSTRUCTION
DECODER AND
MECHINE CYCLE
ENCODER
REGISTER BANKS
CPU
INTERRUPT
RAM ROM TIMER
BUS IO PORTS UART
Function Micro Processor Micro Controller
Task Multi task Specific task
Consists CPU CPU+Memory+ADC+tim
er+Oscillator+IO ports
Oscillator Speed High clock speed(GHz) Low clock speed(MHz)
Memory Need External Memory Inbuilt Memory
Cost High Low
Example 8085,8086 8051,PIC,AVR
Real Time
Applications
Computer Washing Machine,
Electronic Toys,
Microwave oven etc.,
Harvard Architectures
• Used mostly in RISC CPUs
• Separate program bus and data
bus: can be of different widths
• For example, PICs use:
– Data memory (RAM): a small
number of 8bit registers
– Program memory (ROM):
12bit, 14bit or 16bit wide (in
EPROM, FLASH, or ROM)
Von-Neumann Architecture
• Used in: 80X86 (CISC PCs)
• Only one bus between CPU and
memory
• RAM and program memory share
the same bus and the same
memory, and so must have the
same bit width
• Bottleneck: Getting instructions
interferes with accessing RAM
CPU
RAM ROM CPU
RAM
&
ROM
Reduced Instruction Set
Computer (RISC)
– Used in: SPARC,
ALPHA, Atmel AVR, etc.
– Few instructions
(usually < 50)
– Only a few addressing
modes
– Executes 1 instruction in
1 internal clock cycle
(Tcyc)
Complex Instruction Set
Computer (CISC)
– Used in: 80X86, 8051,
68HC11, etc.
– Many instructions
(usually > 100)
– Several addressing modes
– Usually takes more than 1
internal clock cycle
(Tcyc) to execute
ROM RAM
Read only Read & Write
Non volatile Volatile
Types
PROM
EPROM
EEPROM
Flash
Types
SRAM
DRAM
• A compiler is a computer program that transforms source code
written in a programming language into another computer language
(object code).
Example: Turbo C 3.0, Turbo C 4.5
• A cross compiler is similar to the compilers but we write a program
for the target processor (like 8051 and its derivatives) on the host
processors (like computer of x86).
Example: HITECH C, CCS, Keil C
INTRO TO THE ARDUINO
• Topics:
• The Arduino
• Digital IO
• Analog IO
• Serial Communication
ARDUINO UNO
GETTING STARTED
• Check out: http://arduino.cc/en/Guide/HomePage
1. Download & install the Arduino environment (IDE)
(not needed in lab)
2. Connect the board to your computer via the USB cable
3. If needed, install the drivers (not needed in lab)
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
ARDUINO IDE
SELECT SERIAL PORT AND BOARD
INPUT/OUTPUT
DIGITAL INPUT/OUTPUT
• Digital IO is binary
valued—it’s either on or
off, 1 or 0
• Internally, all
microprocessors are
digital, why?
1
0
PIN DIAGRAM
ARDUINO DIGITAL I/0
pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Electronic stuff
Output pins can provide 40 mA of current
Writing HIGH to an input pin installs a 20KΩ
pullup
OUR FIRST PROGRAM
IO PINS
EXP1:- Blinking LED
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
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
}
Controlling LED with Switch
EXP2:- SWITCH
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
}
Connect LCD with arduino
Steps:
 LCD RS pin to digital pin 12
 LCD Enable pin to digital pin 11
 LCD D4 pin to digital pin 5
 LCD D5 pin to digital pin 4
 LCD D6 pin to digital pin 3
 LCD D7 pin to digital pin 2
 LCD R/W pin to ground
EXP3:- LCD Interface
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}
Topic 3: Analog Input
• Think about music stored on a CD---an analog signal
captured on digital media
– Sample rate
– Word length
• Resolution: the number of different voltage levels (i.e., states) used to
discretize an input signal
• Resolution values range from 256 states (8 bits) to 4,294,967,296 states
(32 bits)
• The Arduino uses 1024 states (10 bits)
• Smallest measurable voltage change is 5V/1024 or 4.8 mV
• Maximum sample rate is 10,000 times a second
Arduino Analog Input
How does ADC work?
• How does ADC work
• Excel Demonstration
Topic 3: Analog Output
• Can a digital device produce analog output?
• Analog output can be simulated using pulse
width modulation (PWM)
EXP4:Temperature Monitor
#include <LiquidCrystal.h>
const int analogInPin = A0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorValue1 = 0;
void setup()
{ lcd.begin(16, 2);}
void loop()
{
lcd.setCursor(0,0);
lcd.print(" " );
lcd.setCursor(0,1);
lcd.print(" " );
sensorValue1 = analogRead(analogInPin);
sensorValue1=((sensorValue1*0.0009765625)*100;
lcd.setCursor(0,0);
lcd.print("Temperature = " );
lcd.setCursor(0,1);
lcd.print(sensorValue1);
delay(1000);
}
Topic 4: Serial Communication
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
Open the Serial Monitor and Upload
the Program
Some Commands
• Serial.begin()
- e.g., Serial.begin(9600)
• Serial.print() or Serial.println()
- e.g., Serial.print(value)
• Serial.read()
• Serial.available()
• Serial.write()
• Serial.parseInt()
Serial-to-USB chip---what does it do?
The LilyPad and Fio Arduino require an external USB to TTY
connector, such as an FTDI “cable”.
In the Arduino Leonardo a single microcontroller runs the
Arduino programs and handles the USB connection.
Two different communication
protocols
Serial (TTL):
USB Protocol
• Much more complicated
In-class Exercise 3: Serial
Communication
Modify your program from in-class
exercise 2-part 2 to control the intensity
of the LED attached to pin 9 based on
keyboard input.
Use the Serial.parseInt() method to read
numeric keyboard input as an integer.
An input of 9 should produce full intensity
and an input of 0 should turn the LED off.
GSM Transmitter
void setup() {
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
Serial.begin(9600); // initialize the serial communications:
}
void loop()
{
// when characters arrive over the serial port...
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGF=1");
delay(1000);
Serial.println("AT+CMGS="9500546055"");
delay(1000);
Serial.println("HAIO");
delay(1000);
Serial.write(0x1A);
delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000);
delay(1000); delay(1000); delay(1000); delay(1000); delay(1000);
while(1);
}
Zigbee Transmitter
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("H"); //turn on the LED
delay(3000);
Serial.println("L");//turn off the LED
delay(3000);
}
Zigbee receiver
char msg = ' '; //contains the message from arduino sender
const int led = 13; //led at pin 13
void setup() {
Serial.begin(9600);//Remember that the baud must be the same on both arduinos
pinMode(led,OUTPUT);
}
void loop() {
while(Serial.available() > 0) {
msg=Serial.read();
if(msg=='H') {
digitalWrite(led,HIGH);
}
if(msg=='L') {
digitalWrite(led,LOW);
}
msg = ' ';
delay(1000);
}
}
Thank You

More Related Content

Similar to arduinoedit.pptx (20)

Arduino and c programming
Arduino and c programmingArduino and c programming
Arduino and c programming
 
Indroduction arduino
Indroduction arduinoIndroduction arduino
Indroduction arduino
 
Indroduction the arduino
Indroduction the arduinoIndroduction the arduino
Indroduction the arduino
 
Arduino
ArduinoArduino
Arduino
 
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
 
arduino.pdf
arduino.pdfarduino.pdf
arduino.pdf
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
Arduino.pptx
Arduino.pptxArduino.pptx
Arduino.pptx
 
Arduino
ArduinoArduino
Arduino
 
wireless charging of an electrical vechicle 3
wireless charging of an electrical vechicle 3wireless charging of an electrical vechicle 3
wireless charging of an electrical vechicle 3
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming Familiarization
 
embedded system and AVR
embedded system and AVRembedded system and AVR
embedded system and AVR
 
Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)Connecting Hardware to Flex (360MAX)
Connecting Hardware to Flex (360MAX)
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
Arduino wk2
Arduino wk2Arduino wk2
Arduino wk2
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
 

Recently uploaded

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 

arduinoedit.pptx

  • 1. Arduino Gowtham Thamilarasu Senior Embedded Design Engineer Sparks Automations
  • 2. TOP LEVEL MANAGEMENT HUMAN RESOURCE MANAGEMENT PROJECT MANAGER TEAM LEADER TEAM MEMBERS
  • 4. • What is a microcontroller and a microprocessor? • Difference between microprocessor & microcontroller? • Evolution of Embedded in day-to-day life • Types of Architecture • Types of Processors
  • 5. • Program Memory and Data Memory • Hard Disk is RAM or ROM? • Compiler Vs Cross Compiler • Pipeline • Application • Arduino Microcontroller
  • 8. Function Micro Processor Micro Controller Task Multi task Specific task Consists CPU CPU+Memory+ADC+tim er+Oscillator+IO ports Oscillator Speed High clock speed(GHz) Low clock speed(MHz) Memory Need External Memory Inbuilt Memory Cost High Low Example 8085,8086 8051,PIC,AVR Real Time Applications Computer Washing Machine, Electronic Toys, Microwave oven etc.,
  • 9.
  • 10. Harvard Architectures • Used mostly in RISC CPUs • Separate program bus and data bus: can be of different widths • For example, PICs use: – Data memory (RAM): a small number of 8bit registers – Program memory (ROM): 12bit, 14bit or 16bit wide (in EPROM, FLASH, or ROM) Von-Neumann Architecture • Used in: 80X86 (CISC PCs) • Only one bus between CPU and memory • RAM and program memory share the same bus and the same memory, and so must have the same bit width • Bottleneck: Getting instructions interferes with accessing RAM CPU RAM ROM CPU RAM & ROM
  • 11. Reduced Instruction Set Computer (RISC) – Used in: SPARC, ALPHA, Atmel AVR, etc. – Few instructions (usually < 50) – Only a few addressing modes – Executes 1 instruction in 1 internal clock cycle (Tcyc) Complex Instruction Set Computer (CISC) – Used in: 80X86, 8051, 68HC11, etc. – Many instructions (usually > 100) – Several addressing modes – Usually takes more than 1 internal clock cycle (Tcyc) to execute
  • 12. ROM RAM Read only Read & Write Non volatile Volatile Types PROM EPROM EEPROM Flash Types SRAM DRAM
  • 13. • A compiler is a computer program that transforms source code written in a programming language into another computer language (object code). Example: Turbo C 3.0, Turbo C 4.5 • A cross compiler is similar to the compilers but we write a program for the target processor (like 8051 and its derivatives) on the host processors (like computer of x86). Example: HITECH C, CCS, Keil C
  • 14.
  • 15. INTRO TO THE ARDUINO • Topics: • The Arduino • Digital IO • Analog IO • Serial Communication
  • 17. GETTING STARTED • Check out: http://arduino.cc/en/Guide/HomePage 1. Download & install the Arduino environment (IDE) (not needed in lab) 2. Connect the board to your computer via the USB cable 3. If needed, install the drivers (not needed in lab) 4. Launch the Arduino IDE 5. Select your board 6. Select your serial port 7. Open the blink example 8. Upload the program
  • 19. SELECT SERIAL PORT AND BOARD
  • 20.
  • 22. DIGITAL INPUT/OUTPUT • Digital IO is binary valued—it’s either on or off, 1 or 0 • Internally, all microprocessors are digital, why? 1 0
  • 23.
  • 25. ARDUINO DIGITAL I/0 pinMode(pin, mode) Sets pin to either INPUT or OUTPUT digitalRead(pin) Reads HIGH or LOW from a pin digitalWrite(pin, value) Writes HIGH or LOW to a pin Electronic stuff Output pins can provide 40 mA of current Writing HIGH to an input pin installs a 20KΩ pullup
  • 28. EXP1:- Blinking LED // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever 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 }
  • 30. EXP2:- SWITCH const int buttonPin = 2; const int ledPin = 13; int buttonState = 0; void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }
  • 31. Connect LCD with arduino Steps:  LCD RS pin to digital pin 12  LCD Enable pin to digital pin 11  LCD D4 pin to digital pin 5  LCD D5 pin to digital pin 4  LCD D6 pin to digital pin 3  LCD D7 pin to digital pin 2  LCD R/W pin to ground
  • 32. EXP3:- LCD Interface // include the library code: #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // Turn off the display: lcd.noDisplay(); delay(500); // Turn on the display: lcd.display(); delay(500); }
  • 33. Topic 3: Analog Input • Think about music stored on a CD---an analog signal captured on digital media – Sample rate – Word length
  • 34. • Resolution: the number of different voltage levels (i.e., states) used to discretize an input signal • Resolution values range from 256 states (8 bits) to 4,294,967,296 states (32 bits) • The Arduino uses 1024 states (10 bits) • Smallest measurable voltage change is 5V/1024 or 4.8 mV • Maximum sample rate is 10,000 times a second Arduino Analog Input
  • 35. How does ADC work? • How does ADC work • Excel Demonstration
  • 36. Topic 3: Analog Output • Can a digital device produce analog output? • Analog output can be simulated using pulse width modulation (PWM)
  • 37. EXP4:Temperature Monitor #include <LiquidCrystal.h> const int analogInPin = A0; LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int sensorValue1 = 0; void setup() { lcd.begin(16, 2);} void loop() { lcd.setCursor(0,0); lcd.print(" " ); lcd.setCursor(0,1); lcd.print(" " ); sensorValue1 = analogRead(analogInPin);
  • 38. sensorValue1=((sensorValue1*0.0009765625)*100; lcd.setCursor(0,0); lcd.print("Temperature = " ); lcd.setCursor(0,1); lcd.print(sensorValue1); delay(1000); }
  • 39. Topic 4: Serial Communication
  • 40.
  • 41. 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
  • 42. Open the Serial Monitor and Upload the Program
  • 43. Some Commands • Serial.begin() - e.g., Serial.begin(9600) • Serial.print() or Serial.println() - e.g., Serial.print(value) • Serial.read() • Serial.available() • Serial.write() • Serial.parseInt()
  • 44. Serial-to-USB chip---what does it do? The LilyPad and Fio Arduino require an external USB to TTY connector, such as an FTDI “cable”. In the Arduino Leonardo a single microcontroller runs the Arduino programs and handles the USB connection.
  • 46. USB Protocol • Much more complicated
  • 47. In-class Exercise 3: Serial Communication Modify your program from in-class exercise 2-part 2 to control the intensity of the LED attached to pin 9 based on keyboard input. Use the Serial.parseInt() method to read numeric keyboard input as an integer. An input of 9 should produce full intensity and an input of 0 should turn the LED off.
  • 48. GSM Transmitter void setup() { lcd.begin(16, 2); // set up the LCD's number of columns and rows: Serial.begin(9600); // initialize the serial communications: } void loop() { // when characters arrive over the serial port... Serial.println("AT"); delay(1000); Serial.println("AT+CMGF=1"); delay(1000); Serial.println("AT+CMGS="9500546055""); delay(1000); Serial.println("HAIO"); delay(1000); Serial.write(0x1A); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); delay(1000); while(1); }
  • 49. Zigbee Transmitter void setup() { Serial.begin(9600); } void loop() { Serial.println("H"); //turn on the LED delay(3000); Serial.println("L");//turn off the LED delay(3000); }
  • 50. Zigbee receiver char msg = ' '; //contains the message from arduino sender const int led = 13; //led at pin 13 void setup() { Serial.begin(9600);//Remember that the baud must be the same on both arduinos pinMode(led,OUTPUT); } void loop() { while(Serial.available() > 0) { msg=Serial.read(); if(msg=='H') { digitalWrite(led,HIGH); } if(msg=='L') { digitalWrite(led,LOW); } msg = ' '; delay(1000); } }