Page 438 - 3-2
P. 438

나 블루투스 소스.


            SERIAL_MARSTER


            #include <SoftwareSerial.h>


            SoftwareSerial BTSerial(16,10); // 5: d1 tx, 4: d2 rx


            void setup(){
            pinMode(9,INPUT);
            Serial.begin(9600);
            BTSerial.begin(9600);
            }


            void loop(){
            delay(50);
            {
            if(BTSerial.available()){
            Serial.write(BTSerial.read());
            }
            if(Serial.available()){
            BTSerial.write(Serial.read());
            }
            }


            if(digitalRead(9) == HIGH)
            {
            BTSerial.print('0');
            }
            else if(digitalRead(9) == LOW)
            {
            BTSerial.print('1');
            }
            else
            {
            BTSerial.print('1');
            }
            }


            SERIAL_SLAVE


            #include <SoftwareSerial.h>


            SoftwareSerial BTSerial(16, 10); // 16: d1 tx, 10: d2 rx




                                                         - 438 -
   433   434   435   436   437   438   439   440   441   442   443