i am using arduino , android phone , and bluetooth..
i have 2 pins .. i need to turn them on or off .. but the problem is that i need to get the status first of those 2 pins .
for example if pin 1 is on , so there is no need to turn it on ...
i need a program that checks the status of my pins .. and when it check, it must give me a feed back on my ON and OFF pins.. please help me ..
I think you must use digitalRead(pin) and after send this state to bluetooth with serial.
int val = 0; // variable to store the read value
int ledPin=13; //Indicator led. If pin 2 or 3 is HIGH red led on.
//We check the pins 2,3.....you can change it....
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
pinMode(2, INPUT); // sets the digital pin 2 as input
pinMode(3, INPUT); // sets the digital pin 3 as input
}
void loop(){
for(int i=2;i<4;i++){
val = digitalRead(i);
if ( val==HIGH ) {
Serial.print(i);//Send to bluetooth HIGH pin
delay(100);
digitalWrite(ledPin,HIGH); //If pin 2 or pin 3 is HIGH the LED 13 on for 1 secs
delay(1000);
digitalWrite(ledPin,LOW);
}
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
}
}
}
You must see in your android screen the HIGH pins...