can i add a code include if statement with bush button to a code receive some state by bluetooth from another arduino
If you can describe it, you can probably do it - you don't have to ask for permission.
i have a code for bluetooth it has a serial available code that receive a character from another Arduino to do something ........ so for this Arduino i want to add bush button on it to turn on the led , when i add the code that contain a bluetooth code for the code how contain a bush button code it doesn't work , i don't now why
No, me neither.
is there any solution ?
I don't know - I can't see what you tried.
Want you want to do is possible but you don't know what you are doing, and nobody else does either. Post your code, and wiring, then you might actually get some help.
this is my code , the upper part for the arduino and the lower part is for bush button
#include <SoftwareSerial.h>
#define led1 8
#define led2 9
#define led3 10
#define led4 11
#define led5 13
char state = ' ' ;
const int BUTTON1 = 4;
const int BUTTON2 = 5;
const int BUTTON3 = 6;
const int BUTTON4 = 7;
void setup() {
pinMode (led1 , OUTPUT );
pinMode (led2 , OUTPUT );
pinMode (led3 , OUTPUT );
pinMode (led4 , OUTPUT );
pinMode (led5 , OUTPUT );
Serial.begin (115200);
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
pinMode(BUTTON3, INPUT);
pinMode(BUTTON4, INPUT);
}
void loop() {
if (Serial.available()>0)
{
state = Serial.read ();
Serial.write (state);
}
digitalWrite (led1 , HIGH );
digitalWrite (led2 , HIGH );
digitalWrite (led3 , HIGH );
digitalWrite (led4 , HIGH );
digitalWrite (led5,HIGH );
if (state =='&')
{
digitalWrite (led1 , HIGH );
digitalWrite (led2 , HIGH );
digitalWrite (led3 , HIGH );
digitalWrite (led4 , HIGH );
digitalWrite (led5,HIGH );
}
if (state==']')
{
digitalWrite (led1 , LOW );//ON
digitalWrite (led2 , HIGH );//OFF
digitalWrite (led3 , HIGH );//OFF
digitalWrite (led4 ,LOW);//ON
digitalWrite (led5,LOW );
delay(60000);
}
if ( state == '*');
{
digitalWrite (led1 , HIGH );
digitalWrite (led2 , HIGH );
digitalWrite (led3 , HIGH );
digitalWrite (led4 ,HIGH );
digitalWrite (led5,HIGH );
delay(60000);
}
if (state=='/')
{
digitalWrite (led1 , HIGH);
digitalWrite (led2 , LOW );
digitalWrite (led3 , LOW );
digitalWrite (led4 ,HIGH);
digitalWrite (led5,LOW );
delay(60000);
}
////////////////////////////////////
digitalWrite (led5 ,HIGH ) ;
if (digitalRead(BUTTON3) == HIGH)
{
digitalWrite(led3, LOW );
digitalWrite(led5, LOW);
} else{
digitalWrite(led3, HIGH);
}
if (digitalRead(BUTTON1) == HIGH)
{
digitalWrite(led1, LOW);
digitalWrite(led5, LOW);
Serial.print ( "ahmad") ;
}
else{
digitalWrite(led1, HIGH);
}
if (digitalRead(BUTTON2) == HIGH)
{
digitalWrite (led2, LOW);
Serial.print ("123");
}
else{
digitalWrite(led2, HIGH );
}
if (digitalRead(BUTTON4) == HIGH)
{
digitalWrite(led4, LOW );
Serial.print ("b11");
}
else
{
digitalWrite(led4 , HIGH);
}
/////////////////////////////////////////////////
}
Oops.
Please remember to use code tags when posting code
You have called the software serial library but are not using it. You might not actually need it but, with the absence of any wiring details, who would know?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.