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