hai gaesss, kita coba pengaplikasian dari transmit data yg sudah laras buat sebelumnya yaaa. contohnya ya ini, menyalakan 3 LED dalma arduino (aplikasinya saja)
pertama-tama siapkan visual studio 2012 hehe, habis itu siapkan aplikasi arduino atau HTERM
1. Buka Visual Studio 2012 , pilih new project habis itu namai project anda
2. Susun Form- form seperti punya saya
3. Atur timer 1 di interval properties nya, menjadi 500. lalu, simpan picture sbg LED nya, kalau punya saya memakai warna hitam dan merah. hitam artinya OFF, merah artinya ON
4. kemudian ikuti saja program yang saya buat
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LED
{
public partial class Form1 : Form
{
Image laras = Properties.Resources.laras;
Image Hanisa = Properties.Resources.Hanisa;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
serialPort1.Open();
}
private void button2_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("1");
pictureBox1.BackgroundImage = Hanisa;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("0");
pictureBox1.BackgroundImage = laras;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
serialPort1.Write(textBox1.Text);
}
private void timer1_Tick(object sender, EventArgs e)
{
if (serialPort1.BytesToRead != 0)
{
textBox2.Text = serialPort1.ReadExisting();
}
}
private void button4_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("2");
pictureBox2.BackgroundImage = Hanisa;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button5_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("3");
pictureBox2.BackgroundImage = laras;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button7_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("4");
pictureBox3.BackgroundImage = Hanisa;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button6_Click(object sender, EventArgs e)
{
try
{
serialPort1.Write("5");
pictureBox3.BackgroundImage = laras;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
5. Lalu jalankan aplikasi HTERM seperti ini, lalu setting COM berlawanan dengan COM yang terdapat pada visual studio dan setting baud nya menjadi 9600 lalu kemudian klik connect.