Arduino
• Arduino is a tool (microcontroller) that helps to control electronics stuff with code.
• Microcontroller is microprocessor with memory, RAM and some other peripheral
connected with it.
• The Arduino Uno is a microcontroller board based on the ATmega328. The
ATmega328 has Flash memory of 32 KB.
1/8
Audirno
Arduino stands in the middle and reads input and control outputs with logic.
2/8
Audirno
Audirno is composed of two components
• Hardware
• Software (Integrated Development Environment)
3/8
Hardware
What does it have?
Figure: Aurdino UNO 4/8
Software
• Every Arduino program has void setup() and void loop().
• Program runs in linear fashion.
• Program is case sensitive.
5/8
Software
Three things are required to declare a variable
• Data type
• Variable name
• value
6/8
Software
Some basic functions for controlling the Arduino board
• pinMode(pin, mode): Configure the specified pin to behave either as an input or an
output.
• digitalWrite(pin, value): Write a ”HIGH” or ”LOW” to a digital pin.
• digitalRead(pin): Reads the value from a specified digital pin, either ”HIGH” or
”LOW”.
• delay(2000): Pause the program for the amount of time (in milliseconds).
• analogWrite(pin, value): Writes analog value (PWM) to a pin. It can be used to
light an LED at varying brightness or drive a motor at various speeds.
• analogRead(A0): Read the value from the specified analog pin. ATmega328 it has a
10-bit analog-to-digital converter. This means that it can map input voltage between
0 and 5V into integer values between 0 and 1023.
7/8
Serial communication
• “Serial” because data is broken into bits, each sent one after another in a single wire.
• Serial.begin(9600) initializes serial communication between the Arduino board and
the computer, setting the data transfer rate to 9600 bits per second.
• Compiling turns 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
8/8