0% found this document useful (0 votes)
26 views

Modul 04 Traffic Light

This document provides instructions for a practical module on microcontrollers using an Arduino UNO. The objectives are for students to be able to use I/O on the Arduino UNO and create a traffic light program. The practical involves setting up a traffic light circuit according to the schematic. The code provided sets pin modes for the red, yellow, and green LEDs of one traffic light and initializes them to the on state. Students are instructed to observe the output.

Uploaded by

Mubarok Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Modul 04 Traffic Light

This document provides instructions for a practical module on microcontrollers using an Arduino UNO. The objectives are for students to be able to use I/O on the Arduino UNO and create a traffic light program. The practical involves setting up a traffic light circuit according to the schematic. The code provided sets pin modes for the red, yellow, and green LEDs of one traffic light and initializes them to the on state. Students are instructed to observe the output.

Uploaded by

Mubarok Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

MODUL PRAKTIK MIKROKONTROLLER

Modul 04 – Traffic Light


TUJUAN A. Mahasiswa mampu menggunakan I/O pada Arduino UNO
B. Mahasiswa mampu membuat program Traffic Light

PRAKTIKUM 1. Buatlah rangkaian seperti schematic berikut!


01
DUINO1

microcontrolandos.blogspot.com

AREF
13
PB5/SCK
12
PB4/MISO
RESET 11
~PB3/MOSI/OC2A
10
~ PB2/SS/OC1B
9
~ PB1/OC1A
8
PB0/ICP1/CLKO
ATMEGA328P-PU
1121

DIGITAL (~PWM)

7
ANALOG IN

PD7/AIN1
6
A0 ~ PD6/AIN0
PC0/ADC0 5
A1 ~ PD5/T1
PC1/ADC1 4
A2 PD4/T0/XCK
PC2/ADC2 3
A3 ~ PD3/INT1
PC3/ADC3 2
A4 PD2/INT0
PC4/ADC4/SDA 1
A5 TX PD1/TXD
PC5/ADC5/SCL 0
RX PD0/RXD

ARDUINO UNO R3

2. Tuliskan source code berikut.


void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT); //merah
pinMode(12, OUTPUT); //kuning
pinMode(11, OUTPUT); //hijau

digitalWrite(13, 1);
digitalWrite(12, 1);
digitalWrite(11, 1);
}

void loop() {
// put your main code here, to run repeatedly:

}
3. Amati Outputnya!

1
MODUL PRAKTIK MIKROKONTROLLER

PRAKTIKUM 1. Buatlah rangkaian seperti schematic berikut!


02
DUINO1

microcontrolandos.blogspot.com
AREF
13
PB5/SCK
12
PB4/MISO
RESET 11
~PB3/MOSI/OC2A
10
~ PB2/SS/OC1B
9
~ PB1/OC1A
8
PB0/ICP1/CLKO

ATMEGA328P-PU
1121

DIGITAL (~PWM)
7
ANALOG IN

PD7/AIN1
6
A0 ~ PD6/AIN0
PC0/ADC0 5
A1 ~ PD5/T1
PC1/ADC1 4
A2 PD4/T0/XCK
PC2/ADC2 3
A3 ~ PD3/INT1
PC3/ADC3 2
A4 PD2/INT0
PC4/ADC4/SDA 1
A5 TX PD1/TXD
PC5/ADC5/SCL 0
RX PD0/RXD

ARDUINO UNO R3

2. Tuliskan source code berikut.


void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT); //merah1
pinMode(12, OUTPUT); //kuning1
pinMode(11, OUTPUT); //hijau1

pinMode(10, OUTPUT); //merah2


pinMode(9, OUTPUT); //kuning2
pinMode(8, OUTPUT); //hijau2

/*
digitalWrite(13, 1);
digitalWrite(12, 1);
digitalWrite(11, 1);
digitalWrite(10, 1);
digitalWrite(9, 1);
digitalWrite(8, 1);
*/
}

void loop() {
// put your main code here, to run repeatedly:

2
MODUL PRAKTIK MIKROKONTROLLER

digitalWrite(13, 1); //merah1 on


digitalWrite(8, 1); //hijau2 on
delay(2000); //delay 2 detik
digitalWrite(13, 0); //merah1 off
digitalWrite(8, 0); //hijau2 off
digitalWrite(12, 1); //kuning1 on
digitalWrite(9, 1); //kuning2 on
delay(2000);
digitalWrite(11, 1); //hijau1 on
digitalWrite(10, 1); //merah2 on
digitalWrite(12, 0); //kuning1 on
digitalWrite(9, 0); //kuning2 on
delay(2000);
digitalWrite(11, 0); //hijau1 off
digitalWrite(10, 0); //merah2 off
}

3. Amati Outputnya!

TUGAS 1. Buatlah program untuk traffic light 3 lane.


2. Buatlah program untuk traffic light 4 lane.

You might also like