밑의 사진처럼 아두이노 키트를 만들어준다.
아두이노 IDE에 코드를 작성해서 업로드, 스케치 버튼을 눌러 실행시켜준다.
//LED
const int ledPin = 10;
char inputVal = 0;
//온도
float temp;
//조도
const int lightPin = A1;
//초음파
const int trig_pin = 11;
const int echo_pin = 12;
void setup() {
Serial.begin(9600);
pinMode(ledPin,OUTPUT);
//초음파
pinMode(trig_pin , OUTPUT);
pinMode(echo_pin,INPUT);
}
void loop() {
if(Serial.available()){
inputVal = Serial.read();
if(inputVal == '1'){
digitalWrite(ledPin,HIGH);
Serial.print("LED:");
Serial.print("ON");
Serial.print("_");
}
else if(inputVal == '0'){
digitalWrite(ledPin,LOW);
Serial.print("LED:");
Serial.print("OFF");
Serial.print("_");
}
}
//온도
int val = analogRead(A0);
temp = val*0.48828125;
Serial.print("TMP:");
Serial.print(temp);
Serial.print("_");
//조도
int lightValue = analogRead(lightPin);
Serial.print("LIGHT:");
Serial.print(lightValue);
Serial.print("_");
//초음파
digitalWrite(trig_pin,LOW);
delayMicroseconds(2);
digitalWrite(trig_pin,HIGH);
delayMicroseconds(10);
digitalWrite(trig_pin,LOW);
long duration = pulseIn(echo_pin,HIGH);
long distance = (duration/2)/29.1;
Serial.print("DIS:");
Serial.println(distance);
delay(500);
}
그러면 현재 온도, 초음파, 조도 값이 출력되는 것을 확인 할 수 있다.
이번에는 인텔리제이로 와서 controller 패키지를 만들고 ArduinoController를 작성해준다.
package com.example.demo.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@Slf4j
@RequestMapping("/arduino")
public class ArduinoController {
@GetMapping("/index")
public void index(){
log.info("GET/arduino/index");
}
}
그리고 restcontroller 패키지를 만들고 ArduinoRestController 클래스도 만들어 준다.
package com.example.demo.restconstroller;
import com.fazecast.jSerialComm.SerialPort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
@RestController
@Slf4j
@RequestMapping("/arduino")
public class ArduinoRestController {
private SerialPort serialPort;
private OutputStream outputStream;
private InputStream inputStream;
private String LedLog;
private String TmpLog;
private String LightLog;
private String DistanceLog;
@GetMapping("/connection/{COM}")
public ResponseEntity<String> setConnection(@PathVariable("COM") String COM, HttpServletRequest request) {
log.info("GET /arduino/connection " + COM + " IP: " + request.getRemoteAddr());
if (serialPort != null) {
serialPort.closePort();
serialPort = null;
}
//Port Setting
serialPort = SerialPort.getCommPort(COM);
//Connection Setting
serialPort.setBaudRate(9600);
serialPort.setNumDataBits(8);
serialPort.setNumStopBits(0);
serialPort.setParity(0);
serialPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING,2000,0);
boolean isOpen = serialPort.openPort();
log.info("isOpen ? " + isOpen);
if (isOpen) {
this.outputStream = serialPort.getOutputStream();
this.inputStream = serialPort.getInputStream();
//----------------------------------------------------------------
//수신 스레드 동작
//----------------------------------------------------------------
Worker worker = new Worker();
Thread th = new Thread(worker);
th.start();
return new ResponseEntity("Connection Success!", HttpStatus.OK);
} else {
return new ResponseEntity("Connection Fail...!", HttpStatus.BAD_GATEWAY);
}
}
@GetMapping("/led/{value}")
public void led_Control(@PathVariable String value, HttpServletRequest request) throws IOException {
log.info("GET /arduino/led/value : " + value + " IP : " + request.getRemoteAddr());
if (serialPort.isOpen()) {
outputStream.write(value.getBytes());
outputStream.flush();
}
}
@GetMapping("/message/led")
public String led_Message() throws InterruptedException {
return LedLog;
}
@GetMapping("/message/tmp")
public String tmp_Message() {
return TmpLog;
}
@GetMapping("/message/light")
public String light_Message() {
return LightLog;
}
@GetMapping("/message/distance")
public String distance_Message() {
return DistanceLog;
}
//----------------------------------------------------------------
// 수신 스레드 클래스
//----------------------------------------------------------------
class Worker implements Runnable {
DataInputStream din;
@Override
public void run() {
din = new DataInputStream(inputStream);
try{
while(!Thread.interrupted()) {
if (din != null) {
String data = din.readLine();
System.out.println("[DATA] : " + data);
String[] arr = data.split("_"); //LED ,TMP , LIGHT , DIS // 3,4
try {
if (arr.length > 3) {
LedLog = arr[0];
TmpLog = arr[1];
LightLog = arr[2];
DistanceLog = arr[3];
} else {
TmpLog = arr[0];
LightLog = arr[1];
DistanceLog = arr[2];
}
}catch(ArrayIndexOutOfBoundsException e1){e1.printStackTrace();}
// if(data.startsWith("LED:")){
// LedLog = data;
// }else if(data.startsWith("TMP:")) {
// TmpLog = data;
// }else if(data.startsWith("LIGHT:")){
// LightLog = data;
// }else if(data.startsWith("DIS:")){
// DistanceLog = data;
// }
}
Thread.sleep(200);
}
}catch(Exception e){
e.printStackTrace();
}
}
}
//----------------------------------------------------------------
}
다음은 templates에 arduino 패키지를 만들고 index.html 파일을 만들어 준다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>INDEX</h1>
<div>
<fieldset style="width:250px;">
<legend>CONNECTION</legend>
<div style="display:flex;justify-content : space-between;">
<input class="com_port">
<button class="conn_btn">CONN</button>
</div>
</fieldset>
<fieldSet style="width:250px;">
<legend>LED</legend>
<div style="display:flex;justify-content:space-between;">
<button class="led_on">LED ON</button>
|
<button class="led_off">LED OFF</button>
</div>
</fieldSet>
</div>
<div style="display:flex;">
<fieldSet style="width:100px;">
<legend>LED상태</legend>
<span class="led_info"></span>
</fieldSet>
<fieldSet style="width:100px;">
<legend>온도센서</legend>
<span class="tmp_info"></span>
</fieldSet>
<fieldSet style="width:100px;">
<legend>조도센서</legend>
<span class="light_info"></span>
</fieldSet>
<fieldSet style="width:100px;">
<legend>초음파센서</legend>
<span class="distance_info"></span>
</fieldSet>
</div>
<!-- axios cdn -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.5.0/axios.min.js" integrity="sha512-aoTNnqZcT8B4AmeCFmiSnDlc4Nj/KPaZyB5G7JnOnUEkdNpCZs1LCankiYi01sLTyWy+m2P+W4XM+BuQ3Q4/Dg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
const led_on_btn = document.querySelector('.led_on');
const led_off_btn = document.querySelector('.led_off');
const led_info_el = document.querySelector('.led_info');
const tmp_info_el = document.querySelector('.tmp_info');
const light_info_el = document.querySelector('.light_info');
const distance_info_el = document.querySelector('.distance_info');
const messageInterval=null;
const conn_btn = document.querySelector('.conn_btn');
conn_btn.addEventListener('click',function(){
const port = document.querySelector('.com_port').value;
axios.get(`/arduino/connection/${port}`)
.then(response=>{
console.log(response.status);
if(response.status == 200)
{
if(messageInterval!=null){
clearInterval(messageInterval); //기존 요청 반복 제거
}
//만약 연결에 성공했다면 요청
messageInterval = setInterval(()=>{
req_led_info_func();
req_tmp_info_func();
req_light_info_func();
req_distance_info_func();
},1000);
}
})
.catch(error=>{});
});
led_on_btn.addEventListener('click',function(){
axios.get('/arduino/led/1')
.then(response=>{})
.catch(error=>{});
});
led_off_btn.addEventListener('click',function(){
axios.get('/arduino/led/0')
.then(response=>{})
.catch(error=>{});
});
//----------------------------------------------------------------
// Message Received Interval Function
//----------------------------------------------------------------
//1초마다 반복요청
const req_led_info_func = ()=>{
axios.get('/arduino/message/led')
.then(response=>{
led_info_el.innerHTML = response.data;
})
.catch(error=>{});
}
const req_tmp_info_func = ()=>{
axios.get('/arduino/message/tmp')
.then(response=>{
tmp_info_el.innerHTML = response.data;
})
.catch(error=>{});
}
const req_light_info_func = ()=>{
axios.get('/arduino/message/light')
.then(response=>{
light_info_el.innerHTML = response.data;
})
.catch(error=>{});
}
const req_distance_info_func = ()=>{
axios.get('/arduino/message/distance')
.then(response=>{
distance_info_el.innerHTML = response.data;
})
.catch(error=>{});
}
</script>
</body>
</html>
그리고 실행시켜 포트를 연결시키면 각종 값들이 출력되는 것을 확인 할 수 있다.
인텔리제이로 서버를 연결시킨 상태에서 visual studio로 간다.
폼을 만들어 주고 코드들을 작성해본다.
- Form1.cs
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;
using System.IO.Ports;
using System.Threading;
//추가
using System.Net.Http;
using System.Net;
using System.IO;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private SerialPort serialPort = new SerialPort();
public Form1()
{
InitializeComponent();
}
private void conn_btn_Click(object sender, EventArgs e)
{
String port = this.comboBox1.Items[this.comboBox1.SelectedIndex].ToString();
Console.WriteLine("PORT : " + port);
HttpWebRequest request = null;
HttpWebResponse response = null;
try
{
request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/connection/" + port);
request.Method = "GET";
request.ContentType = "application/json";
//request.Timeout = 30 * 1000;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Console.WriteLine("RESPONSE CODE : " + response.StatusCode);
}
}
catch (Exception ex)
{
Console.WriteLine("Ex : " + ex);
}
}
private void led_on_btn_Click(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/led/1");
request.Method = "GET";
request.ContentType = "application/json";
//request.Timeout = 30 * 1000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine("LED BTN : ON" );
}
private void led_off_btn_Click(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/led/0");
request.Method = "GET";
request.ContentType = "application/json";
//request.Timeout = 30 * 1000;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine("LED BTN : OFF");
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/message/led");
request.Method = "GET";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string leds = sr.ReadToEnd();
this.textBox1.AppendText(leds);
Console.WriteLine("LED : " + leds);
}
private void button2_Click(object sender, EventArgs e)
{
textBox2.Text = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/message/light");
request.Method = "GET";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string lights = sr.ReadToEnd();
this.textBox2.AppendText(lights);
Console.WriteLine("LIGHT : " + lights);
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/message/tmp");
request.Method = "GET";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string tmps = sr.ReadToEnd();
this.textBox3.AppendText(tmps);
Console.WriteLine("TMP : " + tmps);
}
private void button4_Click(object sender, EventArgs e)
{
textBox4.Text = "";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost:8080/arduino/message/distance");
request.Method = "GET";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string distances = sr.ReadToEnd();
this.textBox4.AppendText(distances);
Console.WriteLine("DIS : " + distances);
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void SerialPort_DataReceived(Object sender, SerialDataReceivedEventArgs e)
{
String recvData = this.serialPort.ReadLine();
Console.WriteLine(recvData);
//LED 신호전달 문자열
if (recvData.StartsWith("LED:"))
{
Invoke(new Action(() =>
{
this.textBox1.Text = recvData.Replace("LED:", "");
}));
Thread.Sleep(10);
}
//조도센서 전달 문자열
if (recvData.StartsWith("LIGHT:"))
{
Invoke(new Action(() =>
{
this.textBox2.Text = recvData.Replace("LIGHT:", "");
}));
Thread.Sleep(10);
}
//온도센서 전달 문자열
if (recvData.StartsWith("TMP:"))
{
Invoke(new Action(() =>
{
this.textBox3.Text = recvData.Replace("TMP:", "");
}));
Thread.Sleep(10);
}
//초음파센서 전달 문자열
if (recvData.StartsWith("DIS:"))
{
Invoke(new Action(() =>
{
this.textBox4.Text = recvData.Replace("DIS:", "");
}));
Thread.Sleep(10);
}
}
}
}
- Form1.cs (자동으로 생김)
namespace WindowsFormsApp1
{
partial class Form1
{
/// <summary>
/// 필수 디자이너 변수입니다.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 사용 중인 모든 리소스를 정리합니다.
/// </summary>
/// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form 디자이너에서 생성한 코드
/// <summary>
/// 디자이너 지원에 필요한 메서드입니다.
/// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.conn_btn = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.led_off_btn = new System.Windows.Forms.Button();
this.led_on_btn = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.conn_btn);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Location = new System.Drawing.Point(23, 25);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(261, 60);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection";
//
// conn_btn
//
this.conn_btn.Location = new System.Drawing.Point(174, 21);
this.conn_btn.Name = "conn_btn";
this.conn_btn.Size = new System.Drawing.Size(75, 23);
this.conn_btn.TabIndex = 1;
this.conn_btn.Text = "연결";
this.conn_btn.UseVisualStyleBackColor = true;
this.conn_btn.Click += new System.EventHandler(this.conn_btn_Click);
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Items.AddRange(new object[] {
"COM1",
"COM2",
"COM3",
"COM4",
"COM5",
"COM6",
"COM7",
"COM8",
"COM9",
"COM11"});
this.comboBox1.Location = new System.Drawing.Point(7, 21);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(141, 20);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.led_off_btn);
this.groupBox2.Controls.Add(this.led_on_btn);
this.groupBox2.Location = new System.Drawing.Point(23, 100);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(261, 83);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "LED";
//
// led_off_btn
//
this.led_off_btn.Location = new System.Drawing.Point(141, 20);
this.led_off_btn.Name = "led_off_btn";
this.led_off_btn.Size = new System.Drawing.Size(108, 48);
this.led_off_btn.TabIndex = 1;
this.led_off_btn.Text = "OFF";
this.led_off_btn.UseVisualStyleBackColor = true;
this.led_off_btn.Click += new System.EventHandler(this.led_off_btn_Click);
//
// led_on_btn
//
this.led_on_btn.Location = new System.Drawing.Point(7, 20);
this.led_on_btn.Name = "led_on_btn";
this.led_on_btn.Size = new System.Drawing.Size(108, 48);
this.led_on_btn.TabIndex = 0;
this.led_on_btn.Text = "ON";
this.led_on_btn.UseVisualStyleBackColor = true;
this.led_on_btn.Click += new System.EventHandler(this.led_on_btn_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Controls.Add(this.textBox2);
this.groupBox3.Location = new System.Drawing.Point(23, 264);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(261, 44);
this.groupBox3.TabIndex = 2;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "조도센서";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(7, 17);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(159, 21);
this.textBox2.TabIndex = 0;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(7, 17);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(159, 21);
this.textBox3.TabIndex = 0;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.button3);
this.groupBox4.Controls.Add(this.textBox3);
this.groupBox4.Location = new System.Drawing.Point(23, 326);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(261, 44);
this.groupBox4.TabIndex = 3;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "온도센서";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(7, 17);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(159, 21);
this.textBox4.TabIndex = 0;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.button4);
this.groupBox5.Controls.Add(this.textBox4);
this.groupBox5.Location = new System.Drawing.Point(23, 389);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(261, 44);
this.groupBox5.TabIndex = 3;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "초음파센서";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.button1);
this.groupBox6.Controls.Add(this.textBox1);
this.groupBox6.Location = new System.Drawing.Point(23, 204);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(261, 44);
this.groupBox6.TabIndex = 4;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "LED센서";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(7, 17);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(159, 21);
this.textBox1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(180, 15);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(180, 15);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(180, 15);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 3;
this.button3.Text = "button3";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(180, 15);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(75, 23);
this.button4.TabIndex = 4;
this.button4.Text = "button4";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(380, 455);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button conn_btn;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button led_off_btn;
private System.Windows.Forms.Button led_on_btn;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button1;
}
}
모두 작성하고 실행시켜보면 버튼을 누를때마다 textbox와 콘솔창에 해당 값들이 출력되는 것을 확인 할 수 있다.
'IT수업 > 임베디드' 카테고리의 다른 글
IT 수업 24주차 (193) 아두이노 웹 연결 (1) | 2024.06.03 |
---|---|
IT 수업 23주차 (185) 아두이노_조도센서, 온도센서, 초음파센서 (0) | 2024.05.28 |
IT 수업 23주차 (184) 아두이노_ 신호보내기 2 (0) | 2024.05.28 |
IT 수업 23주차 (181) 아두이노 신호 보내기 (0) | 2024.05.27 |
IT 수업 20주차 (127) 아두이노 기본 설치 (0) | 2024.05.07 |