Arduino 2
Arduino 2
Arduino 2
Microcontrollers
(Practical)
◉ Arduino Boards
◉ Arduino IDE
◉ Adding Arduino library in Proteus
◉ Arduino Programming Basics
Digital
Analog
Serial
Introduction to Arduino
◉ Arduino Uno
◉ Arduino Mega 1280
◉ Arduino Mega 2560
Arduino UNO
Arduino UNO
Arduino UNO Specifications
◉ Microcontroller ATmega328
◉Operating Voltage 5V
◉Input Voltage (recommended) 7-12V
◉Input Voltage (limits) 6-20V
◉Digital I/O Pins 14 (of which 6 provide PWM output)
◉Analog Input Pins 6
◉DC Current per I/O Pin 40 mA
◉DC Current for 3.3V Pin 50 mA
◉Flash Memory 32 KB (ATmega328)
◉SRAM 2 KB (ATmega328)
◉EEPROM 1 KB (ATmega328)
◉Clock Speed 16 MHz
Arduino Mega 2560
Arduino Mega2560 Specifications
◉ Microcontroller ATmega2560
◉ Operating Voltage 5V
◉ Input Voltage (recommended) 7-12V
◉ Input Voltage (limits) 6-20V
◉ Digital I/O Pins 54 (15 PWM output)
◉ Analog Input Pins 16
◉ DC Current per I/O Pin 40 mA
◉ DC Current for 3.3V Pin 50 mA
◉ Flash Memory 256 KB
◉ SRAM 8 KB
◉ EEPROM 4 KB
◉ Clock Speed 16 MHz
Arduino IDE
Verify/ Compile Upload New Open Save
◉ pinMode()
◉ digitalWrite()
◉ digitalRead()
pinMode()
Description: Configures the specified pin to behave either as an input or an output.
Syntax: pinMode(pin, mode);
Parameters
pin: the number of the pin whose mode you wish to set
mode: INPUT, OUTPUT, or INPUT_PULLUP.
Returns: None
Digital I/O
digitalWrite()
◉ Description: Write a HIGH or a LOW value to a digital pin.
◉ Syntax: digitalWrite(pin, value)
◉ Parameters
pin: the pin number
value: HIGH or LOW
Returns: none
Digital I/O
◉digitalRead()
◉Description: Reads the value from a specified digital pin, either HIGH or LOW.
◉Syntax
digitalRead(pin);
◉Parameters
pin: the number of the digital pin you want to read (int)
Returns: HIGH or LOW
Serial
◉ Serial.available()
◉ Serial.begin (speed)
◉ Serial.read()
◉ Serial.write(val) , Serial.write(str) ,Serial.write(buf, len)
◉ Serial.print( ), Serial.println( )
Analog I/O
◉ analogReference()
◉ analogRead( pin)
◉ analogWrite(pin, val)-----PWM
Steps to program in Arduino IDE and simulate in Proteus.
Proteus Schematic
E.g 3: Display the reading from temperature sensor LM35 on
Virtual Terminal/ Serial Monitor
◉ 1. Upload the program from Examples/ Communication/ ASCII Table and observe
the effect on Virtual Terminal
◉ 2. Consider that a potentiometer is connected to an analog input pin, write a
program that reads that voltage and turns ON a specific LED according to the given
input:
◉ If voltage is in between 0 to 2, the LED on pin:13 is turned ON.
◉ If voltage is in between 2 to 3.5, the LED on pin:14 is turned ON.
◉ If voltage is in between 3.5 to 5, the LED on pin:15 is turned ON.
Tasks
◉ 3.Design a system, that continuously checks Serial data, if data is “FAN”, it
should turn on FAN and turn off HEATER, and if received data is “HTR”, the
heater should turn ON and Fan OFF.
Device Rx 12 Fan
Arduino UNO
3 Heater
Tasks:
◉ 4. Read data from Serial port and if data on Serial port is x, your name should be sent
over serial port.
Thanks!
Any questions ?