Вы находитесь на странице: 1из 3

// son las variables del boton fisico

int boton=7;

int estado;

// el led del boto de la app

int led=13;

// el led que varia brillo

int Red_LED_Pin = 9;

int Red_value=0; // varia de 0 a 255

//variable por donde viajan datos

char BluetoothData; // the data received from bluetooth serial link

//grafica

int interval=100; //Gives the serial link and app a chance to process data

float voltage; //Assumes 0-1023 range over 5V

int pot=A0;

void setup()

Serial.begin (9600);

pinMode(Red_LED_Pin, OUTPUT);

pinMode(13,OUTPUT);

pinMode(7, INPUT); // boton

}
void loop() {

// progrmacion del boton fisico

estado=digitalRead(7);

if (estado==HIGH) {

//digitalWrite(13,HIGH);

Serial.print("*LR255G0B0*");} //Red

if (estado==LOW)

//digitalWrite(13,LOW);

Serial.print("*LR175G200B0*"); }//verde

//+++++++++++++++++++++++++++++++++++++++//

//grafico

Serial.print("*G"); //using 'G' as Graph 1 receive char in app

for(int i=0;i<8;i++){

voltage=analogRead(i)*0.0048828;

Serial.print(String(voltage)+",");

Serial.print("*");

//grafico

// LA APP ENVIA DATOS AL ARDUINO

if (Serial.available())

{
BluetoothData=Serial.read(); //Get next character from bluetooth

//PULSADOR DE APP

if(BluetoothData=='D') digitalWrite(13,HIGH);

if(BluetoothData=='d') digitalWrite(13,LOW);

//POTENCIOMETRO DE APP

if(BluetoothData=='Y') Red_value=Serial.parseInt(); //Read Red value

analogWrite( Red_LED_Pin, Red_value);

Вам также может понравиться