Intelligent V2X Design [202502-ISE2234-001]
INTRODUCTION TO ARDUINO AND
SENSORS
PROFESSOR CHO CHONG DU ( 조종두 교수님 ) AMIN AL ( 아민알 )
[ 문의 ] 032-860-7321 [ 문의 ] 010-6853-6648
cdcho@[Link] alaminanik@[Link]
10/19/2025 1
Arduino UNO
Model: UNO
Microcontroller: ATmega328P
Input Voltage (recommended): 7~12V
Digital I/O Pins: 14 (6 PWM OUTPUT)
Analog Input Pins : 6
SRAM: 2KB
DC Current per I/O Pin: 20mA
DC Current for 3.3V Pin: 50mA
10/19/2025 2
Arduino MEGA
Model: MEGA
Microcontroller: ATmega2560
Input Voltage (recommended):
7~12V
Digital I/O Pins: 54 (15 PWM OUTPUT)
Analog Input Pins : 16
SRAM: 8KB
DC Current per I/O Pin: 20mA
DC Current for 3.3V Pin: 50mA
10/19/2025 3
Analog and Digital Signals
Analog signals are continuous signals that
represent physical quantities such as sound,
light, and temperature. An analog signal can
take on any value within a range of values,
and it changes smoothly over time. An
example of an analog signal is a human voice
when speaking into a microphone. The
microphone converts the sound waves into an
electrical signal that varies in amplitude and
frequency, which can then be transmitted
through a wire or over the airwaves.
10/19/2025 4
Analog and Digital Signals
Digital signals are discrete signals that
represent information using a sequence
of 0s and 1s. Digital signals are used to
represent numerical values, text,
images, and other types of data. Unlike
analog signals, digital signals can only
take on specific values, and they change
abruptly in discrete steps.
10/19/2025 5
Pulse Width Modulation
(PWM)
PWM (Pulse Width Modulation) is a
technique used to control the amount of
power delivered to electrical devices,
especially in Arduino. It's commonly
used for dimming LEDs, controlling the
speed of motors, and simulating analog
output using digital pins.
10/19/2025 6
How PWM Works
Digital Signals: Arduino uses
digital signals that can either
be HIGH (5V) or LOW (0V).
PWM allows you to simulate
varying levels of voltage
between 0 and 5V by
switching between HIGH and
LOW very quickly.
10/19/2025 7
How PWM Works
Arduino Uno R3 has six PWM
pins, numbered 3, 5, 6, 9, 10,
11. These pins are marked
with a negated symbol " ~ ".
These pins can generate
pulses based on the input
given to them. Arduino
supports pulses that are 8 bits
wide, which means there are
256 possible levels (0 to 255).
[Link]
10/19/2025 8
10/19/2025 9
analogWrite()
1. Control the Brightness of an LED
2. Control the Speed of a DC Motor
3. Generate a Sound with a Buzzer or Speaker
4. Control the Color of an RGB LED
5. Control the Brightness of Multiple LEDs
10/19/2025 10
analogWrite()
10/19/2025 11
analogRead()
1. Read a Potentiometer
2. Measure Light Intensity
3. Measure Temperature Using a Thermistor
4. Read a Joystick
10/19/2025 12
analogRead()
10/19/2025 13
digitalRead()
Reads the value from a specified digital pin, either HIGH or LOW.
1. Read the State of a Button (ON/OFF Switch)
2. Detect an Object with an Infrared (IR) Sensor
3. Use a Limit Switch for Position Sensing
4. Read Multiple Button Inputs
5. Detect Water Level Using a Water Sensor
10/19/2025 14
digitalWrite()
Reads the value from a specified digital pin, either HIGH or LOW.
1. Turn an LED ON and OFF
2. Control a Relay to Turn a Device ON/OFF
3. Control a Buzzer to Produce Sounds
4. Control Multiple LEDs Independently
10/19/2025 15
pinMode()
Input: Configures the pin as an input pin. Use this when you want to read
values from sensors, buttons, etc.
Output: Configures the pin as an output pin. Use this when you want to
send signals to LEDs, motors, relays, etc.
10/19/2025 16
Differences?
Function Purpose Input/Output Type Value Range Typical Use Cases
analogWrite()
digitalWrite()
analogRead()
digitalRead()
10/19/2025 17
Practice
• Print numbers from 0 to 10 and then back down to 0 in a loop.
• Simulate rolling a 6-sided dice and display random values from 1 to 6.
• Generate the Fibonacci sequence and display it in the Serial Monitor.
10/19/2025 18
Practice
10/19/2025 19
10/19/2025 20
Practice
• Count odd numbers from 1 to 20 and print them in reverse order.
• Check for prime numbers from 1 to 50 and print only the primes.
• Even or Odd: Ask the user to enter a number, then print whether it is
even or odd.
• Positive, Negative, or Zero: Input a number and print its sign.
• Maximum of Three Numbers: Ask for three numbers and print the
largest.
10/19/2025 21