Mikrokontroler Arduino
Mikrokontroler Arduino
Mikrokontroler Arduino
Mario Norman Syah
Departemen Teknik Elektro
Universitas Negeri Semarang
Arduino Board
Arduino Board
MEGA
UNO ESP32
NANO-ESP32
UNO NANO
PWR IN USB
(to Computer)
RESET
SCL\SDA
Arduino Pinout (I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS SDA
SCL
Arduino Shield
Komponen elektronika
Name Image Type Function Notes
Push Button Digital Input Switch - Closes Polarized, needs
or opens circuit resistor
Trim Analog Input Variable resistor Also called a
Trimpot.
potentiometer
Photoresistor Analog Input Light Dependent Resistance varies
Resistor (LDR) with light.
Relay Digital Output Switch driven by Used to control
a small signal larger voltages
Temp Sensor Analog Input Temp Dependent
Resistor
Flex Sensor Analog Input Variable resistor
Input Output
Tombol – Saklar LED
Sensor Cahaya Motor
Sensor Suhu Servo
Sensor Kelembapan Buzzer
Sensor Infrared Relay
… …
Analog vs Digital
Source: Digital vs Analog Arduino: Differences, Usage & Code Examples (besomi.com)
Arduino IDE
Code Syntax pada Arduino
Code Syntax pada Arduino
digitalWrite()
analogWrite()
digitalRead()
analogRead()
Serial communication
Simulation
<Boolean> Description
( ) == ( ) is equal?
( ) != ( ) is not equal?
()> () greater than
( ) >= ( ) greater than or equal
()< () less than
( ) <= ( ) less than or equal
Conditional Statements
Digital Input
• Set digital Input:
pinMode (pinNumber, INPUT);
serial.
POWER
5V / 3.3V /
GND Digital I\O
PWM(3, 5, 6, 9, 10,
11)
Analog
INPUTS
Serial Port
• Supported Baud Rates
• 300
• 1200
• 2400
• 4800
• 9600
• 19200
• 38400
• 57600
• 115200
Serial Terminal
Src: Developing the pulse width modulation tool (PWMT) for two timer mechanism technique in
microcontrollers
Istilah
• Duty Cycle (D): Perbandingan waktu ON (Ton) dan OFF (Toff)
• T = Ton + Toff
• D = Ton / Toff
• Generate menggunakan analogWrite()
• Pin PWM Arduino = 3, 5, 6, 9, 10, 11
• Nilai = 0 - 255
Src: Developing the pulse width modulation tool (PWMT) for two timer mechanism technique in
microcontrollers
PWM di Arduino
Src: https://docs.arduino.cc/language-reference/en/functions/analog-io/analogWrite/
Analog Input
Arduino menggunakan 10-bit A/D Converter:
Nilai input yang didapat adalah 0 – 1023
•0V→0
• 5 V → 1023
Code:
int sensorValue = analogRead(A0);
Analog Sensors
3 Pin Potentiometer = var. resistor sering disebutVoltage Divider Circuit
wiper
fixed
ends
1.0 V 1.0 V
Contoh Sensor
• Sensor Suhu dan Kelembaban • Sensor Kecepatan
• Sensor PIR (Passive Infrared Sensor) • Sensor Aliran Air
• Sensor Akselerometer dan Gyroscope • Sensor Api
• Sensor Tegangan • Sensor Kelembaban Tanah
• Sensor Arus • Sensor Getaran
• Sensor Cahaya • Sensor Warna
• GPS • Sensor PH
• Sensor Ketinggian Air • Sensor Berat
• Sensor Suara
• Sensor Jarak
Link Project
• Serial Komunikasi: Serial Komunikasi 2 - Wokwi ESP32, STM32, Arduino
Simulator
• Keypad Arduino: keypad arduino - Wokwi ESP32, STM32, Arduino
Simulator
• Sensor Suhu dan Kelembapan DHT11: DHT11 Arduino - Wokwi ESP32,
STM32, Arduino Simulator
• Kontrol LED dengan Blynk: LATIHAN-LED-IOT.ino Copy - Wokwi ESP32,
STM32, Arduino Simulator
• Kontrol LED dengan Blynk 2: Project UTS - Wokwi ESP32, STM32, Arduino
Simulator
• Tutorial LED Blynk: https://youtu.be/5LWq6zGcppM?si=JejlKIevDDnp69FE
• PWM, Push button, Potensiometer, Sensor Jarak:
https://www.tinkercad.com/things/k9koDF16ofm-pwm