µµ¼­(BOOK)
Å°Æ®(KIT)
ƯÆÇ »óÇ°
Á¹¾÷ÀÛÇ°&ÀüÀÚ±âÃÊ
ÀÀ¿ë¸ðµâ
ÀüÀÚºÎÇ°
¸ðÅÍ
±â±¸
¿£Å¬·ÎÁ®
°³ÀΰáÁ¦¿ë
 
°í°´¼¾ÅÍ °Ô½ÃÆÇ
ÀÚÀ¯°Ô½ÃÆÇ
MCU ÅëÇÕ °Ô½ÃÆÇ
°­ÁÂ-RaspberryPi
°­ÁÂ-µå·Ð(ÄõµåÄßÅÍ)
°­ÁÂ-¾ÆµÎÀ̳ë(±âÃÊ)
°­ÁÂ-¾ÆµÎÀ̳ë(ÀÀ¿ë)
½ÅÁ¦Ç°/½Å±â¼ú ¼Ò°³
DIY °øÀÛ °Ô½ÃÆÇ
À±±³¼öÀÇ ¿¬±¸½Ç Ä®·³
 
 
 
1 ÀÚ·á½ÇÀÌ¿ë½Ã Âü°í»çÇ×
 
 
2 2024³â °©Áø³â (Ë£òãÒ´) »õ..
 
 
3 »ç¹«½Ç ÀÌÀü ¾È³»
 
 
4 2023 °è¹¦³â »õÇØ º¹ ¸¹ÀÌ..
 
 
5 AVR128DA64 Á¤º¹ Ãâ°£¾È³»
 
 
 
 
 
 
 ¢Ï : 02-776-4868

 £Æ: 02-779-6757
À̸ÞÀϹ®ÀÇ
 
¢Ñ ÆòÀÏ(¿ù~±Ý) : 10~17½Ã
¢Ñ ÁÖ¸», °øÈÞÀÏ ÈÞ¹«
 
±¹¹Î822437-04-008415
¢Ñ ¿¹±ÝÁÖ : À̹ÎÈñ(¿È»ç(OHM»ç))
 
 
1 À±±³¼öÀÇ ¸¶ÀÌÅ©·ÎÇÁ·Î¼¼¼­ ¿ùµå
 
2 (ÁÖ)¼®¿µºê¶óÀ̽ºÅæ
 

 

 
°­ÁÂ-¾ÆµÎÀ̳ë(ÀÀ¿ë)
 
2014. 06. 07 (12:29)
Á¦¸ñ[¾ÆµÎÀ̳ë ÀÀ¿ë] 2. ºí·çÅõ½º ½¯µå - 2
ÀÛ¼ºÀÚohmsa Á¶È¸ : 6462

2. ºí·çÅõ½º ½¯µå(Bluetooth Shield) – 2


Áö³­ °­Á¿¡¼­ ´Ù·é ºí·çÅõ½º ½¯µå´Â ½½·¹ÀÌºê ¸ðµå¸¦ ÀÌ¿ëÇؼ­, ¸¶½ºÅÍ µð¹ÙÀ̽º¿¡¼­ ºí·çÅõ½º ½¯µå¸¦ °Ë»öÇÑ ÈÄ¿¡ ¿¬°áÇÏ´Â ¹æ½ÄÀ¸·Î ½ÇÇèÇØ º¸¾Ò´Ù.

 

À̹ø °­Á¿¡¼­´Â ºí·çÅõ½º ½¯µå¸¦ ¸¶½ºÅÍ ¸ðµå·Î ¼³Á¤À» Çؼ­ »ç¿ëÇÏ´Â ¹æ¹ý¿¡ ´ëÇؼ­ ¾Ë¾Æ º¸µµ·Ï ÇÑ´Ù.

Áö³­ °­Á¿¡¼­´Â LED ȸ·Î¸¦ ±¸¼ºÇÏ¿´´Ù¸é, À̹ø °­Á¿¡¼­´Â ½ºÀ§Ä¡ ÀÔ·ÂÀ» ÀÌ¿ëÇϵµ·Ï ÇÑ´Ù. D9 Æ÷Æ®¸¦ ÀÔ·ÂÀ¸·Î »ç¿ëÀ» Çϸç, Ç®¾÷ ÀúÇ×À» ½ºÀ§Ä¡¿Í ¿¬°áÇÏ¿© ´­·¶À» ¶§, LOW ÀÔ·ÂÀÌ µÇµµ·Ï ±¸¼ºÀ» ÇÑ´Ù.

 

À§ ȸ·Î´Â ÀÌÇظ¦ µ½±â À§ÇÑ °ÍÀ̸ç, ÀÌÀü °­ÁÂ¿Í °°ÀÌ ¾ÆµÎÀÌ³ë ¿ì³ë º¸µå À§¿¡ ºí·çÅõ½º ½¯µå¸¦ ¿¬°áÇÑ ÈÄ¿¡ ºê·¹µåº¸µå ½¯µå¸¦ ¿¬°áÇؼ­ À§¿Í °°Àº ȸ·Î¸¦ ±¸¼ºÇÑ´Ù



ÀÌÀü °­Á¿¡¼­ Ãß°¡ ½ÃÄ×´ø ¿¹Á¦ Áß¿¡¼­ ¾Æ·¡ÀÇ ¿¹Á¦¸¦ ºÒ·¯¿Â´Ù.




 

#include                         // Software Serial Port

 

#define RxD         6

#define TxD         7

 

#define PINBUTTON   9                               // pin of button

 

#define DEBUG_ENABLED  1

 

String retSymb   = "+RTINQ=";                     // start symble when there's any return

// caution that ';'must be included, and make sure the slave name is right.

String slaveName = ";SM-C101";                

int nameIndex = 0;

int addrIndex = 0;

 

String recvBuf;

String slaveAddr;

 

String connectCmd = "\r\n+CONN=";

 

SoftwareSerial blueToothSerial(RxD,TxD);

 

void setup()

{

    Serial.begin(9600);

    pinMode(RxD, INPUT);

    pinMode(TxD, OUTPUT);

    pinMode(PINBUTTON, INPUT);

   

    setupBlueToothConnection();

    //wait 1s and flush the serial buffer

    delay(1000);

    Serial.flush();

    blueToothSerial.flush();

}

 

void loop()

{

   

    static unsigned char state = 0;             // led off

   

    if(!digitalRead(PINBUTTON))

    {

        state = 1-state;

       

        Serial.println("button on");

       

        blueToothSerial.println("button on");

       

        delay(10);

        while(!digitalRead(PINBUTTON))       // until button release

        {

            delay(10);

        }

       

        Serial.println("button off");

        blueToothSerial.println("button off");

    }

}

 

 

void setupBlueToothConnection()

{

    // Set BluetoothBee BaudRate to default baud rate 38400

    blueToothSerial.begin(38400);

    // set the bluetooth work in master mode

blueToothSerial.print("\r\n+STWMOD=1\r\n");       

// set the bluetooth name as "SeeedBTMaster"        

blueToothSerial.print("\r\n+STNA=SeeedBTMaster\r\n");           

// Auto-connection is forbidden here

blueToothSerial.print("\r\n+STAUTO=0\r\n");                     

delay(2000);  // This delay is required.

    blueToothSerial.flush();

    blueToothSerial.print("\r\n+INQ=1\r\n");   //make the master inquire

    Serial.println("Master is inquiring!");

    delay(2000); // This delay is required.

 

    //find the target slave

    char recvChar;

    while(1)

    {

        if(blueToothSerial.available())

        {

            recvChar = blueToothSerial.read();

            recvBuf += recvChar;

            //get the position of slave name

            nameIndex = recvBuf.indexOf(slaveName); //nameIndex -= 1;

          //decrease the ';' in front of the slave name, to get the position of the end of the slave address

            if ( nameIndex != -1 )

            {

                //Serial.print(recvBuf);

                //get the start position of slave address

                addrIndex = (recvBuf.indexOf(retSymb,(nameIndex - retSymb.length()- 18) ) + retSymb.length());

                //get the string of slave address

                slaveAddr = recvBuf.substring(addrIndex, nameIndex); break;

            }

        }

    }

   

    //form the full connection command

    connectCmd += slaveAddr;

    connectCmd += "\r\n";

    int connectOK = 0;

    Serial.print("Connecting to slave:");

    Serial.print(slaveAddr);

    Serial.println(slaveName);

    //connecting the slave till they are connected

   

    do

    {

        blueToothSerial.print(connectCmd);//send connection command

        recvBuf = "";

        while(1)

        {

            if(blueToothSerial.available()){

                recvChar = blueToothSerial.read();

                recvBuf += recvChar;

                if(recvBuf.indexOf("CONNECT:OK") != -1)

                {

                    connectOK = 1;

                    Serial.println("Connected!");

                    blueToothSerial.print("Connected!");

                    break;

                }

                else if(recvBuf.indexOf("CONNECT:FAIL") != -1)

                {

                    Serial.println("Connect again!");

                    break;

                }

            }

        }

    }while(0 == connectOK);

}

 

 


 

À§ ÄÚµå´Â ¸¶½ºÅÍ ¸ðµå·Î ¼³Á¤µÈ ºí·çÅõ½º ¸ðµâÀÌ ÁöÁ¤µÈ ½½·¹À̺ê ÀåÄ¡¸¦ °Ë»öÇÑ ÈÄ¿¡, ¼­·Î ¿¬°áµÇ¸é ½ºÀ§Ä¡ÀÇ ÀԷ¿¡ µû¶ó¼­ ÁöÁ¤µÈ ¸Þ½ÃÁö¸¦ ½½·¹À̺ê ÀåÄ¡¿¡ Àü¼ÛÇÏ´Â ÄÚµåÀÌ´Ù.

 

¿ø·¡ ÄÚµå¿Í´Â Á¶±Ý ´Ù¸£±â ¶§¹®¿¡, À§ ¼Ò½º ÄÚµåÀÇ ºÓÀº»ö ºÎºÐÀ» ¾Ë¸Â°Ô ¼öÁ¤Çؼ­ »ç¿ëÇÏ¸é µÈ´Ù.

 

String slaveName = ";SM-C101";

 

½½·¹À̺ê ÀåÄ¡ÀÇ À̸§À» ÁöÁ¤ÇÏ´Â ºÎºÐÀ¸·Î ¿ø·¡´Â

 

           String slaveName = ";SeeedBTSlave";

 

¿Í °°ÀÌ ÁöÁ¤ÀÌ µÇ¾î ÀÖ¾ú´Ù. ÀÌ ¿¹Á¦´Â µÎ °³ÀÇ ºí·çÅõ½º ½¯µå¸¦ ¸¶½ºÅÍ¿Í ½½·¹À̺ê·Î ±¸ºÐÀ» ÇÑ ÈÄ¿¡ Å×½ºÆ®ÇÏ´Â ¿¹Á¦·Î, º» °­Á¿¡¼­´Â ÇÑ °³ÀÇ ºí·çÅõ½º ½¯µå¸¦ ÀÌ¿ëÇϱ⠶§¹®¿¡ ¾à°£ÀÇ ¼öÁ¤À» Çϵµ·Ï ÇÑ´Ù.

 

º» °­Á¿¡¼­´Â ½º¸¶Æ®ÆùÀÇ ºí·çÅõ½º Å͹̳ΰúÀÇ ¿¬°áÀ» À§Çؼ­ ½½·¹À̺ê ÀåÄ¡°¡ ½º¸¶Æ®ÆùÀÌ µÇ°í, ¿©±â¿¡¼­ »ç¿ëµÇ´Â ½½·¹À̺ê À̸§Àº °¢°¢ÀÇ ½º¸¶Æ®Æù ¸¶´Ù Ʋ¸®´Ù.




º» °­Á¿¡¼­ »ç¿ëµÈ ½º¸¶Æ®ÆùÀÇ ºí·çÅõ½º ÀåÄ¡ÀÇ À̸§Àº À̱⠶§¹®¿¡ ½½·¹À̺ê À̸§À» String slaveName = ";SM-C101"; ¿Í °°ÀÌ Ç¥ÇöÀ» Çß´Ù.

 


º»ÀÎÀÇ ½º¸¶Æ®ÆùÀÇ ¼³Á¤À» ¡°³» µð¹ÙÀ̽º¸¦ °Ë»ö¡± °¡´ÉÇϵµ·Ï ¼³Á¤ ÇÑ ÈÄ¿¡, ÄÄÆÄÀÏ ÈÄ¿¡ ¾÷·Îµå¸¦ ÇØ º¸µµ·Ï ÇÏÀÚ.


Á¤»óÀûÀ¸·Î ¿¬°áÀÌ µÇ¸é, ½Ã¸®¾ó Å͹̳Πâ¿¡ À§¿Í °°Àº ¿¬°á ¸Þ½ÃÁö°¡ Ãâ·ÂÀÌ µÇ°í,



ºí·çÅõ½º Å͹̳ο¡¼­µµ ÀÇ À̸§À¸·Î ¿¬°áÀÌ µÈ °ÍÀ» º¼ ¼ö ÀÖ´Ù.

 

¹Ì¸® ±¸¼ºÇÑ ½ºÀ§Ä¡¸¦ On/Off ÇÔ¿¡ µû¶ó¼­ ºí·çÅõ½º Å͹̳ο¡ ¾Æ·¡¿Í °°Àº ¸Þ½ÃÁö°¡ Àü¼ÛÀÌ µÇ¸é Á¤»óÀûÀ¸·Î µ¿ÀÛÀ» ÇÏ´Â °ÍÀÌ´Ù.



¹°·Ð, ½Ã¸®¾ó Å͹̳ο¡¼­µµ ¾Æ·¡¿Í °°Àº ¸Þ½ÃÁö°¡ Ãâ·ÂÀÌ µÈ´Ù



¿¹Á¦ ÄÚµå´Â »ó¼¼ÇÏ°Ô ¼³¸íÀ» ÇÏÁö´Â ¾Ê°Ú´Ù. ºí·çÅõ½º¸¦ ÃʱâÈ­ Çϰųª ½½·¹À̺ê ÀåÄ¡¸¦ ã´Â ºÎºÐÀº º¯°æ ¾øÀÌ ±×´ë·Î ÀÌ¿ëÀÌ °¡´ÉÇϱ⠶§¹®¿¡, ÁÖ¿ä ºÎºÐÀÇ ¼öÁ¤ÀÌ ÇÊ¿äÇÑ ºÎºÐ¿¡ ´ëÇؼ­¸¸ °£´ÜÈ÷ ¼³¸íÇÏ¿´´Ù.

¿¹Á¦¸¦ õõÈ÷ º¸¸é¼­ ±× »ç¿ë¿¡ ´ëÇؼ­ ÀÍÈ÷µµ·Ï ÇÏ°í, À̹ø °­Á¿¡¼­ ´Ù·ç°í ÀÖ´Â ºí·çÅõ½º ¸ðµâÀÇ ¸¶½ºÅÍ ¸ðµåÀÇ ¼³Á¤ ¹æ¹ý¿¡ ´ëÇؼ­ ÀÍÈú ¼ö ÀÖµµ·Ï ÇÑ´Ù.


http://blog.naver.com/rnc_ohm

ºñ¹Ð¹øÈ£ È®ÀÎ ´Ý±â
name password
  Content name date hits
[¾ÆµÎÀ̳ë ÀÀ¿ë] 2. ºí·çÅõ½º ½¯µå - 2  
2014/06/07 6462


Copyright ¨Ï µµ¼­ÃâÆÇ ¿È»ç All Rights Reserved. ¢Ï : 02-776-4868 ,£Æ: 02-779-6757
»óÈ£¸í : ¿È»ç(OHM»ç) »ç¾÷Àå¼ÒÀçÁö : ¼­¿ïƯº°½Ã ¿µµîÆ÷±¸ ´ë¸²·Î170-1, 1Ãþ(´ë¸²µ¿)
»ç¾÷ÀÚµî·Ï¹øÈ£ : 416-18-31168 [»ç¾÷ÀÚÁ¤º¸È®ÀÎ] Åë½ÅÆǸž÷½Å°í¹øÈ£ : Á¦2023-¼­¿ï¿ë»ê-1034È£
´ëÇ¥ : À̹ÎÈñ °³ÀÎÁ¤º¸ º¸È£ Ã¥ÀÓÀÚ : Á¤È«±â