hi am trying to make led panel with 2 mode. like manual and automatic with pir.
For example light is controlled by bluetooth app in the there will be three button - select bluetooth, turn on light and turn off light, then auto mode and manual toggle botton
when i set in manual the light should work with on and off
if its in auto mode the light should be there in 50% and when we get pulse from pir the light should be 100% for 1 minute and if there is no pulse is getting from pir it should go to 50%
this the function am trying to build
the below code was got from internet and i tried to alter it
so pls help me to build this one
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX
int counter = 0;
int buttonPin = 13;
char bt_data;
int s = 10; //PIR outPin on digital 10
int led1 = 11; //led1 on 4
int led = 3;
void setup()
{
pinMode(s,INPUT); //Setting Sensor as Input
pinMode(led1,OUTPUT);
pinMode(led,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(mySerial.available()>0){bt_data = mySerial.read();
{
digitalRead(buttonPin);
if(buttonPin = HIGH){
counter+1;
}
else{}
}
{
if(counter == 1)
{
digitalWrite(led1,HIGH);//By default lights off
analogWrite(led1,255/5);
delay(60000); //1 minute delay so that the PIR gets enough hot to function
goto off; //going to off
ON: //the ON statement
{
digitalWrite(led1,HIGH);
if((digitalRead(s))) //if Again sensor input has been read - switch off
{
digitalWrite(led1,HIGH); //switch off
analogWrite(led1,255/5);
delay(6500); //around 7 seconds delay
/* PIR needs at least 5 seconds to function again*/
goto off;
}
else //Else just Be ON
{
goto ON;
}
}
off: //OFF statement
{
digitalWrite(led1,HIGH);
analogWrite(led1,255/5);
if((digitalRead(s))) //if again sensor input has been read - switch ON
{
digitalWrite(led1,HIGH); //switch on
delay(6500); /* PIR needs at least 5 seconds to function again*/
goto ON;
}
else //just be off
{
goto off;
}
}
}
else if(counter == 2)
{
if(Serial.available()>0)
{
char data = Serial.read();
if (data == 'a')
{
digitalWrite(led,HIGH);
}
else if(data == 'b')
{
digitalWrite(led,LOW);
}
}
}
}
}
}