0% found this document useful (0 votes)
11 views5 pages

Arduino Bluetooth Control Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Arduino Bluetooth Control Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ARDUINO CODE

#include <SoftwareSerial.h> // TX RX software library for bluetooth

#include <Servo.h> // servo library


Servo myservo; // servo name

int bluetoothTx = 10; // bluetooth tx to 10 pin


int bluetoothRx = 11; // bluetooth rx to 11 pin ---rx, tx
int Pin2=2;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
pinMode(Pin2,OUTPUT);
digitalWrite(Pin2,LOW);
//Setup usb serial connection to computer
[Link](9600);

//Setup Bluetooth serial connection to android


[Link](9600);
}

void loop()
{
//Read from bluetooth and write to usb serial
if([Link]()> 0 ) // receive number from bluetooth
{
//int dataIn = [Link](); // save the received number
to [Link]();
char dataIn = [Link](); // save the received number
to [Link]();
[Link](dataIn); // serial print current number received from
bluetooth

if (dataIn=='1')
{digitalWrite(Pin2,HIGH);
delay(1000);
}
else if (dataIn=='0')
{digitalWrite(Pin2,LOW);}

}
MIT App Inventor
Diagrama

Bluetooth : HC-06

You might also like