0% found this document useful (0 votes)
99 views11 pages

Praktikum Komunikasi Data 2 Arduino

This document contains an Arduino program for controlling LEDs and a stepper motor via a WiFi connection, and a Visual Basic program for the interface. The Arduino program establishes a WiFi connection and allows control of digital pins and reading of button presses from the client. The Visual Basic program provides a GUI interface for controlling the direction, speed, and angle of the stepper motor, as well as buttons for turning LEDs on and off. It uses timers and sockets to continuously send data to the Arduino.

Uploaded by

Dayuar Dya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views11 pages

Praktikum Komunikasi Data 2 Arduino

This document contains an Arduino program for controlling LEDs and a stepper motor via a WiFi connection, and a Visual Basic program for the interface. The Arduino program establishes a WiFi connection and allows control of digital pins and reading of button presses from the client. The Visual Basic program provides a GUI interface for controlling the direction, speed, and angle of the stepper motor, as well as buttons for turning LEDs on and off. It uses timers and sockets to continuously send data to the Arduino.

Uploaded by

Dayuar Dya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

LAPORAN PRAKTIKUM

KOMUNIKASI DATA 2

DAMAS YUSLI ARFANI


2 AEC
217341056

POLITEKNIK MANUFAKTUR BANDUNG


JURUSAN TEKNIK OTOMASI MANUFAKTUR DAN MEKATRONIKA
BANDUNG
Program Arduino :
#include <ESP8266WiFi.h>

const char* ssid = "AP_PLC";

const char* password = "ProloG16";

WiFiServer server(80);

WiFiClient client;

int i;

int dt;

boolean x = true;

int m = 80;

void setup() {

[Link](115200);

delay(10);

pinMode(16, OUTPUT);

pinMode(5, OUTPUT);

pinMode(4, OUTPUT);

pinMode(0, OUTPUT);

pinMode(2, OUTPUT);

pinMode(14, OUTPUT);

pinMode(12, OUTPUT);

pinMode(13, OUTPUT);

digitalWrite(16, 0);

digitalWrite(5, 0);

digitalWrite(4, 0);

digitalWrite(0, 0);

digitalWrite(2, 0);

digitalWrite(14, 0);

digitalWrite(12, 0);

digitalWrite(13, 0);
[Link]();

[Link]();

[Link]("Connecting to ");

[Link](ssid);

[Link](WIFI_STA);

[Link](ssid, password);

while ([Link]() != WL_CONNECTED) {

delay(500);

[Link](".");

[Link]();

[Link]("");

[Link]("Server started");

[Link]("Use this URL to connect: ");

[Link]("[Link]

[Link]([Link]());

[Link]("/");

void loop() {

if (![Link]()) {

client = [Link]();

if(x==false){

x=true;

[Link]("Your PC is Disconnected");}

return;

} else {
if (x==true){

[Link]("Your PC is Connected");

x=false;

if ([Link]()) {

char SData;

SData = [Link]();

[Link](SData);

if (SData == '1')

digitalWrite(16, HIGH);

} else if (SData == '2') {

digitalWrite(5, HIGH);

} else if (SData == '3') {

digitalWrite(4, HIGH);

} else if (SData == '4') {

digitalWrite(0, HIGH);

} else if (SData == '5') {

digitalWrite(2, HIGH);

} else if (SData == '6') {

digitalWrite(14, HIGH);

} else if (SData == '7') {

digitalWrite(12, HIGH);

} else if (SData == '8') {

digitalWrite(13, HIGH);

} else if (SData == 'a') {

digitalWrite(16, LOW);

} else if (SData == 'b') {

digitalWrite(5, LOW);
} else if (SData == 'c') {

digitalWrite(4, LOW);

} else if (SData == 'd') {

digitalWrite(0, LOW);

} else if (SData == 'e') {

digitalWrite(2, LOW);

} else if (SData == 'f' ) {

digitalWrite(14, LOW);

} else if (SData == 'g') {

digitalWrite(12, LOW);

} else if (SData == 'h') {

digitalWrite(13, LOW);

else if(SData =='q'){

m = 140;

else if (SData=='r')

m=120;

else if (SData=='t')

m=250;

else if(SData ==','){

[Link](", ok");

digitalWrite(2, LOW);

digitalWrite(13, HIGH);

[Link]("1 ok");

delay(m);
digitalWrite(13, LOW);

digitalWrite(12, HIGH);

[Link]("2 ok");

delay(m);

digitalWrite(12, LOW);

digitalWrite(14, HIGH);

[Link]("3 ok");

delay(m);

digitalWrite(14, LOW);

digitalWrite(2, HIGH);

[Link]("4 ok");

delay(m);}}

else if(SData =='.'){

[Link]("/// . ok");

{digitalWrite(13, LOW);

digitalWrite(2, HIGH);

[Link]("1 ok");

delay(m);

digitalWrite(2, LOW);

digitalWrite(14, HIGH);

[Link]("2 ok");

delay(m);

digitalWrite(14, LOW);

digitalWrite(12, HIGH);

[Link]("3 ok");

delay(m);

digitalWrite(12, LOW);

digitalWrite(13, HIGH);

[Link]("4 ok");

delay(m);}}

} }}
Analisis:
Program ini diawali dengan #include
<ESP8266WiFi.h> yang berfungsi untuk
memanggil library ESP8266WiFi. Sehingga kita
data menggunakan sintak yang terdapat di dalam
library tersebut seperti : WiFiServer,WiFiClient,
Client, dan sebagainya.

WiFiServer berfungsi untuk menentukan port


yang akan di pakai.

[Link] berfungsi untuk menentukan mode


wifi

[Link] berfungsi untuk menyambungkan ke


wifi

[Link] berfungsi untuk mengecek status


arduino

if(![Link]) berfungsi untuk memeriksa


apakah sudah ada clien yang terhubung atau
belum

client = [Link] berfungsi untuk mencari


client

[Link] sintak untuk kondisi dimana sudah


ada client yang terhubung

[Link]() berfungsi untuk membaca input dari


client
Visual Basic
Interface:

Program:
Analisis:
Combo1 berfungsi untuk mengatur arah
putaran
Combo2 berfungsi untuk mengatur
kecepatan
Combo3 berfungsi untuk mengatur besar
sudut
[Link] berfungsi untuk menutup koneksi

[Link] berfungsi untuk mengatur


kecepatan mengirim data

Label10 berfungsi sebagai tombol start

Lamp1 – Lamp8 berfungsi sebagai tombol


nyala/mati untuk lampu
Label19 berfungsi sebagai tombol
connect
Label2 berfungsi sebagai tombol
disconnect
Label6 berfungsi sebagai tombol exit
Label7 berfungsi sebagai tombol stop
namun apabila telah selesai
mengirim data maka tombol stop
tidak akan berfungsi walaupun
program di arduino masih berjalan
Option1 berfungsi untuk
mengganti tampilan menjadi
tampilan LED
Option2 berfungsi untuk
mengganti tampilan menjadi
tampilan Motor Stepper
Text3 berfungsi sebagai input
sudut manual. Sehingga
dapat memasukkan besar
sudut sesua keinginan namun
perhitungan ini masih belum
sempurna sehingga semakin
besar sudut maka akan
semakin jelas erronya.
Timer1 berfungsi untuk
mengirim data secara
berulang

You might also like