Sensors Sec1
Sensors Sec1
SENSORS - SECTION1
What is Arduino?
• It is a series of open-source
microcontroller board based
on a diverse range of
microcontrollers (MCU)
• Importance: Widely used in
electronics, automation, and
IoT projects.
• Different Boards: Arduino
Uno, Mega, Nano.
INTRO. TO ARDUINO
• It’s a micro-computer/
microcontroller .
• As any computer it has internal
CPU, RAM, IOs interfaces.
• It’s used for control purposes.
• Arduino uno is reprogrammable,
codes can be ported into it for
specific application.
What is Arduino Uno?
• A microcontroller board based on ATmega328P
Key Components:
• Microcontroller unit
• Digital & Analog Pins
• Power Supply & Voltage Regulators
• USB Interface for programming
Arduino Uno
Board
Layout
Board Components
•Reset Button : This will restart any code that is loaded to the Arduino board
•Ground Pin : There are a few ground pins on the Arduino and they all work the same
•Analog Pins (A0 - A5): These pins read the signal from an analog sensor and convert it to digital
•Digital Input/Output : Pins 0-13 can be used for digital input or output
•PWM ((~3, ~5, ~6, ~9, ~10, ~11): The pins marked with the (~) symbol can simulate analog
output
•USB Connection : Used for powering up your Arduino and uploading sketches
Board Components
• TX/RX : Transmit and receive data indication LEDs
• ATmega Microcontroller : Popular microcontroller chip,
• Power LED Indicator : This LED lights up anytime the board is plugged
in a power source
• DC Power Barrel Jack : This is used for powering your Arduino with a
power supply
• 3.3V Pin : This pin supplies 3.3 volts of power
• 5V Pin : This pin supplies 5 volts of power
steps to write Arduino code
1- BREADBOARD
1- BREADBOARD …
Basic electronics
2- LED
• Light Emitting Diode.
Avo meter
3- RESISTORS
3- BATTERY
6-BATTERY CLIPS
•
Basic electronics
3- JUMPER WIRES MALE
MALE
• To connect two points to each
other without soldering.
Basic electronics
6-REGULATOR
• takes an input voltage of up to
38 V and efficiently reduces it
to 5 V.
Basic electronics
CIRCUITS EXAMPLE
• To turn on a led
Basic electronics
CIRCUITS EXAMPLE
• To turn on a led
Code Structure
/* This
is
a
multi-line
comment */
variables
In Arduino C, identifiers should contain only alphanumeric
characters, dash (-), or underscore(_).
An identifier can only start from an underscore or a letter.
dataType variable_name ;
int x ;
or..
int x = 3;
Variables datatypes
Data type Size range
boolean (8 bit) true/false
byte (8 bit) 0-255
char (8 bit) (A-Z) or -128 to 127
word (16 bit) 0-65535
unsigned int (16 bit) 0-65535
int (16 bit) -32768 to 32767
unsigned long (32 bit) 0-4,294,967,295
long (32 bit) -2,147,483,648 to 2,147,483,647
float (32 bit) -3.4028235E38 to 3.4028235E38
Examples
Arithmetic operators
Comparison
Operators
Boolean Operators
Compound Operators
Operator name Operator simple Description Example
increment ++ Increment operator, increases integer value by one A++ will give 11
decrement -- Decrement operator, decreases integer value by one A-- will give 9
Variables
Scope
Global
local variables Parameters
variables
Control Structures
•if
•if …else…
•for
•switch case
•while
•do… while…
Blinking led Example
Blinking led Example
Blinking led Example