Hey,
I recently picked up this cheap ($15) RF doorbell system and have been playing around with getting to work with a Promini and DFPlayer mini. the plan is to have a wireless Mp3 doorbell using the existing RF system.
After probing about i found that one pin on the IC inside the bell sits at 0v and climbs to 3v when the transmitter is pressed.
I've soldered a wire to the pin hoping that this 0v - 3v could be used as a low, high function on the arduino? if im completely wrong set me straight lol.
Anyway, what's stopping you from trying it out? Just make sure you put two or three diodes and small resistor (200-500 Ohm) in the line to drop the voltage to 3V (I assume you have a 5V Arduino) and limit current (protection of both sides - you don't know what you're connecting to really) and see what happens.
Here is a picture of the IC and the pin that sits at 0v untill the transmitter is pressed. im hoping this change can replace the function of a regular switch. this is the code i've uploaded to the arduino.
D0 of the IC is running into pin2 of the arduino
/*********************************
**Wire:
*Pin10 - player TX;
*Pin11 - player RX;
*pin12 - player BUSY
**********************************/ #include <SoftwareSerial.h> #include <DFPlayer_Mini_Mp3.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int inPin = 2;
int val = LOW;
int play_state = HIGH;
long lastDebounceTime = 0;
long debounceDelay = 500;
void setup () {
pinMode(inPin, INPUT);
pinMode(13, OUTPUT);
Serial.begin (9600);
mySerial.begin (9600);
mp3_set_serial (mySerial); //set softwareSerial for DFPlayer-mini mp3 module
delay(1); // delay 1ms to set volume
mp3_set_volume (30); // value 0~30
}
void loop () {
val = digitalRead(inPin);
play_state = digitalRead(12);// connect Pin12 to BUSY pin of player
if ( ((millis() - lastDebounceTime) > debounceDelay) && (val == HIGH) && (play_state == HIGH)) {
lastDebounceTime = millis();
mp3_play (1);
//zz = ++zz;
//if (zz > 3) { zz = 1; }
digitalWrite(13, HIGH);
}
So you want to use this output to control the Arduino instead? First I figured it's the other way around.
Should work.
Connect the GND of Arduino to the GND of your door bell, 3V should be high enough even on a 5V system to detect as HIGH when you digitalRead() the pin. Otherwise you can always use an analogRead() and see if the value is high enough (should be about 600 for 3V).
please post code between code </> tages, so it looks like this.
Scanning your code I see you have some debounce in it - why? It's not a button.
//Digital Read with Button
int pushButton =2; //digital pin 2 has a push button attached to it. Give it an name
//the setup routine runs once when you press reset
void setup() {
Serial.begin(9600); //initialize serial comm. at 9600 bits per second
pinMode(pushButton, INPUT); //make the push button's pin an input
}
//the loop routine runs over and over again forever
void loop() {
int buttonState = digitalRead(pushButton); //read the input pin
Serial.println(buttonState); //print out the state of the button
delay(1); //delay in between reads for stability
}
and I'm getting 0's when not in use and 1's when the transmitter is pressed. so i guess it is working.
any chance you could point me in the right direction from here? would the code a posted previously work with some alterations? i tried it and nothing happens.
No debouncing needed of course; but you want only to start playing as the pin becomes high so upon change. Keep track of that. You code will be something like this:
#define DOORBELL_PIN 1 // set this to the pin that reads your doorbell.
bool buttonState = false;
void setup() {
pinMode(doorbellPin, INPUT);
}
void loop() {
if (digitalRead(DOORBELL_PIN) && buttonState == false) {
buttonState = true;
playMP3();
}
else buttonState = false;
}
void playMP3() {
// play your mp3 file.
}
Remember to put all functionality in separate functions - that makes copying them into other code a lot easier.
In your case start with an mp3 player example, maybe modify it a bit (move player code into a separate function) and then you can just copy the relevant function into your sketch.