Hello, I was making a project for my school which will go for interschool competition. So in that project it is like "there is a trash can for a common area and all houses trash goes into that 1 big trash can, so that the cleaning worker don't need to roam around the city and collect garbage and in that it tells how much the trash can is filled up and when its 100% it will make a beep sound and send message to workers so that the empty the trash can and go" and in the bluetooth part there is coing an error. Can one pls help me I have to give it to competition on 2nd January.
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
SoftwareSerial BTserial(0,1);
const int rs = 12, ce =13, d4 = 8, d5 = 9, d6 = 10, d7 =11;
LiquidCrystal lcd(rs, ce, d4, d5, d6, d7);
const int buzzerPin = 2;
int analogPinA0 = A0;
int valA0 = 0;
int analogPinA2 = A2;
int valA2 = 0;
int analogPinA3 = A3;
int valA3= 0;
int analogPinA4 = A4;
int valA4 = 0;
void setup() {
BTserial.begin(9600);
lcd.begin(16, 2);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print("DUSTBIN CAPACITY");
pinMode(buzzerPin, OUTPUT);
}
void loop()
{
valA0 = digitalRead(analogPinA0);
valA2 = digitalRead(analogPinA2);
valA3 = digitalRead(analogPinA3);
valA4 = digitalRead(analogPinA4);
if ( valA0==1 && valA2 ==1 && valA3==1 && valA4==1 )
{
lcd.setCursor(0, 1);
lcd.print( "Dustbin is empty " );
send(1);
makeSound(1);
}
else if ( valA0==1 && valA2 ==1 && valA3==1 && valA4==0 )
{
lcd.setCursor(0, 1);
lcd.print( "25% full " );
makeSound(1);
send(1);
}
else if ( valA0==1 && valA2 ==1 && valA3==0 && valA4==0 )
{
lcd.setCursor(0, 1);
lcd.print( "50% full " );
makeSound(1);
send(1);
}
else if( valA0==1 && valA2 ==0 && valA3==0 && valA4==0)
{
lcd.setCursor(0, 1);
lcd.print( "75% full " );
makeSound(1);
send(1);
}
else if (valA0 == 0 && valA2 == 0 && valA3 == 0 && valA4 == 0){
lcd.setCursor(0, 1);
lcd.print("Dustbin is full ");
makeSound(0);
send(0);
}
}
void makeSound(int i)
{
if ( i== 1)
{
long counter = 0;
while(counter <= 100000){
digitalWrite(buzzerPin,HIGH);
counter++;
}
}
else{
digitalWrite(buzzerPin,LOW);
noTone(buzzerPin);
}
}
void send(int a){
if ( a== 1)
{
long counter = 0;
while(counter <= 100000){
BTserial.print("Dustbin is full!!");
BTserial.print(";");
counter++;
}
}
else
{
BTserial.print("Dustbin is empty!!");
BTserial.print(";");
}
}