아두이노 간 통신에 tcp/ip 사용법을 알고 싶습니다.
페이지 정보
작성자 조유신 메일보내기 이름으로 검색 작성일15-06-20 16:52 조회5,176회 댓글1건본문
진동 값을 받아 일정 값 이상에는 플래쉬가 들어오도록 하는 시스템을 만들고 있습니다.
진동 센서 값을 받는것과 켜지는 것은 각각 할 수 있을 것 같은데
그 두 아두이노 사이의 통신을 tcp/ip로 할때 어떤 코드를 써야하는지 모르겠습니다ㅠㅠ
와이파이 실드를 가지고 있고 pc연결없이 아두이노에 코드를 입력해두고 자동으로 쓸수 있게 하려고합니다!
별 상관은 없을 것 같지만
진동센서 값 받는 코드는 이걸 쓰고 있습니다!
int analogPin0 = A0; // input for 1st vibration sensor (MEAS)
int ledPin13 = 13; // LED connected to digital pin 13
int val0 = 0; // variable to store the value read
int low = 10;
int high = 800;
void setup()
{
Serial.begin(9600); // setup serial, has to be stopped to allow LED to lit
pinMode(ledPin13, OUTPUT); // sets the pin as output
pinMode(analogPin0, INPUT); // sets the pin as input
//pinMode(ledPin13, OUTPUT); // sets the pin as output
//pinMode(analogPin5, INPUT); // sets the pin as input
}
void loop()
{
val0 = analogRead(analogPin0); // read the input pin
Serial.println(val0); // debug value
delay(100);
//val1 = analogRead(analogPin5); // read the input pin
//Serial.println(val1); // debug value
if ( val0 > high ) {
digitalWrite(ledPin13, HIGH);
delay(100); //seems very important to get each sensor trigger only ONE LED
}
else{
digitalWrite(ledPin13, LOW);
delay(100);
}
}
댓글목록
하드카피님의 댓글

WiFi 실드를 사용하신다면 아래 소스코드를 응용해보세요
https://github.com/godstale/How-to-make-talking-things/blob/master/chap12/Arduino/wifi_direct_control/wifi_direct_control.ino