Arduino_bluetooth_S03.apk
아두이노소스
#include <SoftwareSerial.h>
SoftwareSerial HC06(2, 3);
char a;
void setup() {
HC06.begin(9600);
Serial.begin(9600);
pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT);
}
void loop() {
if (HC06.available()) {
a=(HC06.read());
if (a=='1') { digitalWrite(8, HIGH); Serial.println("Input : 1"); }
if (a=='2') { digitalWrite(8, LOW); Serial.println("Input : 2"); }
if (a=='3') { digitalWrite(9, HIGH); Serial.println("Input : 3"); }
if (a=='4') { digitalWrite(9, LOW); Serial.println("Input : 4"); }
if (a=='5') { digitalWrite(10, HIGH); Serial.println("Input : 5"); }
if (a=='6') { digitalWrite(10, LOW); Serial.println("Input : 6"); }
if (a=='7') { digitalWrite(11, HIGH); Serial.println("Input : 7"); }
if (a=='8') { digitalWrite(11, LOW); Serial.println("Input : 8"); }
if (a=='?') { Serial.println("Input : ?"); }
}
}