bluetooth hc 06
bluetooth hc 06
หลักการทำงาน
ส่งสัญญาญไปยัง bluetooth hc 06 เมื่อ bluetooth hc 06 ได้รับสัญญาญแล้วก็จะส่งไปยังarduino แล้วแสดงผลไปยังled
Code
#define d1 8
#define d2 9
#define d3 10
#define d4 11
void setup()
{
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
pinMode(d4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
while(Serial.available())
{
char In=Serial.read();
if(In=='a' || In=='A')
{
digitalWrite(d1, HIGH);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
else if(In=='s' || In=='S')
{
digitalWrite(d1, LOW);
digitalWrite(d2, HIGH);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
else if(In=='d' || In=='D')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, HIGH);
digitalWrite(d4, LOW);
}
else if(In=='f' || In=='F')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, HIGH);
}
else if(In=='g' || In=='G')
{
digitalWrite(d1, HIGH);
digitalWrite(d2, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d4, HIGH);
}
else if(In=='h' || In=='H')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
}
}
หลักการทำงาน
ส่งสัญญาญไปยัง bluetooth hc 06 เมื่อ bluetooth hc 06 ได้รับสัญญาญแล้วก็จะส่งไปยังarduino แล้วแสดงผลไปยังled
#define d1 8
#define d2 9
#define d3 10
#define d4 11
void setup()
{
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
pinMode(d4, OUTPUT);
Serial.begin(9600);
}
void loop()
{
while(Serial.available())
{
char In=Serial.read();
if(In=='a' || In=='A')
{
digitalWrite(d1, HIGH);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
else if(In=='s' || In=='S')
{
digitalWrite(d1, LOW);
digitalWrite(d2, HIGH);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
else if(In=='d' || In=='D')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, HIGH);
digitalWrite(d4, LOW);
}
else if(In=='f' || In=='F')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, HIGH);
}
else if(In=='g' || In=='G')
{
digitalWrite(d1, HIGH);
digitalWrite(d2, HIGH);
digitalWrite(d3, HIGH);
digitalWrite(d4, HIGH);
}
else if(In=='h' || In=='H')
{
digitalWrite(d1, LOW);
digitalWrite(d2, LOW);
digitalWrite(d3, LOW);
digitalWrite(d4, LOW);
}
}
}
ความคิดเห็น
แสดงความคิดเห็น