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(0);
makeSound(1);
}
else if (valA0 == 1 && valA2 == 1 && valA3 == 1 && valA4 == 0) {
lcd.setCursor(0, 1);
lcd.print("25% full ");
makeSound(1);
send(0);
} else if (valA0 == 1 && valA2 == 1 && valA3 == 0 && valA4 == 0) {
lcd.setCursor(0, 1);
lcd.print("50% full ");
makeSound(1);
send(0);
} else if (valA0 == 1 && valA2 == 0 && valA3 == 0 && valA4 == 0) {
lcd.setCursor(0, 1);
lcd.print("75% full ");
makeSound(1);
send(0);
} else if (valA0 == 0 && valA2 == 0 && valA3 == 0 && valA4 == 0) {
lcd.setCursor(0, 1);
lcd.print("Dustbin is full ");
makeSound(0);
send(1);
}
}
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(";");
}
}
Please don't hijack threads @pratikbodake. I have deleted the duplicate post you made on an unrelated topic.
Hijacking is against the Arduino forum rules. The reason is that it may sidetrack the discussion, even preventing the creator of the topic from getting the assistance they need.
This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
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(";");
}
}
I have merged yet another hijack post. @pratikbodake please be more respectful of our forum. Repeated hijackings may result in a suspension of your account.
Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Please go back and fix your original post
Please post a schematic. Written descriptions are always more ambiguous than a drawing. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.
What Bluetooth module do you have? A link to a datasheet or where you got it would help.
What Arduino board are you using? In most Arduino boards pins 0 and 1 are the hardware serial (Serial) pins. It makes no sense to use them for software serial. Use the hardware serial (Serial) print to serial monitor to output debugging information, monitor program flow and variable values. The serial port and serial monitor are your best troubleshooting tool. Use different pins for SoftwareSerial. You will be able to upload code without disconnecting the Bluetooth module as well.
In your send() function, I suggest that you put in a delay between sends so as not to spam the receiver. There is no need to send hundreds or thousands of messages per second. Just send one every 5 seconds or so.
Or you could use the picture of a pretty girl as your avatar.
I have noticed that replies to those get fully corrected sketches and do not get gigged for not using code tags.
Hi @groundFungus Im using arduino uno. and im using bluetooth module HC-05 and there is no spam becuase im using receiver not terminal so there is no problem of spam.
OK.
Then my suggestion is to move the software serial to different pins, initialize the hardware serial port and insert some serial prints to see if your code is doing what you think that it is doing and sending what you think that it is sending. If you send to serial monitor you will have to cut down on the frequency of sending.
Still awaiting a schematic.
If you make changes to your code, post the latest version so that we can keep up.
under PCB board there is arduino uno. and you can refer to these both images
The pictures are useless, except to show long wires, which can be a problem.
Please post a hand drawn schematic diagram, with pins, connections and parts clearly labeled.
Also, edit your posts to add code tags.
Those pictures show me very little of what I need to know.
HC05 inputs are not 5V tolerant. There should be a level shifting voltage divider on the HC05 RX pin.
Hi @groundFungus the code for sending message to my phone via bluetooth is working like this code:
#include <SoftwareSerial.h>
SoftwareSerial BTserial(0, 1);
void setup() {
BTserial.begin(9600);
}
void loop() {
send();
}
void send() {
BTserial.print("Dustbin is full!!");
BTserial.print(";");
}
but when i try to use in the main code or I try integrate with the project then it is not sending the messages Idk why?
I made suggestions.
Do you know if the reflective IR sensors are doing what you think?
Do you know if the logic is doing what you think?
Serial prints can tell you a lot.
Please post code properly.
Hi @groundFungus and @jremington I have got some diagram and in bottom left there is the bluetooth sensor is connected.
Is the schematic diagram you posted just something you found on the internet?
Please edit your posts to add code tags.
@pratikbodake,
Your other account has been suspended and this one silenced for 1 week. Please do not create any more accounts. Please use your break from the forum to familiarise yourself with the forum guide.
Thank you.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.