Example Code for Arduino-Incoming Call Control
Last revision 2025/12/19
This article offers a step-by-step guide to using Arduino for incoming call control, featuring hardware and software setup, detailed wiring instructions, and sample code to manage and respond to calls effectively.
Hardware Preparation
- DFR0216 DFRduino UNO R3 x 1
- DFR0781 Audio & BLE/SPP Pass-through Module x 1
- FIT0449 Speaker with Amplifier x 1
- FIT0916-FF DuPont Wires x4
Software Preparation
- Download Arduino IDE: Click to download Arduino IDE
- Download the DFRobot_BT401 library: DFRobot_BT401 library
- About how to install the library?
Wiring Diagram

Other Preparation Work
It is recommended to use hardware serial to drive this module, since it may be unstable when using software serial, which may result in unknown errors.It is suggested to reduce the module's baud rate to 9600 when using software serial driver. Delay 2s for the BT401 to start before initializing.
Sample Code
/*!
* @file answerCall.ino.ino
* @brief Get incoming call information
* @n Experiment Phenomenon:Print phone number and answer the phone when a call comes
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [Eddard]([email protected])
* @version V1.0
* @date 2020-12-29
* @get from https://www.dfrobot.com
* @url https://github.com/cdjq/DFRobot_ID809
*/
#include <DFRobot_BT401.h>
#include <SoftwareSerial.h>
SoftwareSerial btSerial(2, 3); //RX TX
DFRobot_BT401 bt;
void setup(){
Serial.begin(115200);
btSerial.begin(115200);
/*Delay 2s for the BT401 to start*/
delay(2000);
while(!bt.begin(btSerial)){
Serial.println("Init failed, please check wire connection!");
delay(1000);
}
bt.setVOl(30);
bt.switchFunction(bt.eBluetooth);
}
void loop(){
//If a call comes, print phone number and answer it
if(bt.getBtStatus() == bt.eCalling){
Serial.println(bt.getTelNumber());
delay(1000);
//Answer
bt.controltalk(bt.eAnswer);
//Refuse to answer
//bt.controltalk(bt.eRejectCall);
}
//If you are on the phone, print the incoming phone number
if(bt.getBtStatus() == bt.eOnphone){
Serial.print("On the phone:");
Serial.println(bt.getTelNumber());
delay(1000);
//Hang Up
//bt.controltalk(bt.eHangUp);
}
}
Result
When a call comes in, the serial monitor will print the incoming phone number, and the module will answer the call. When on the phone, the serial monitor will print "On the phone:" followed by the phone number.
Additional Information
Ensure the module is paired with a mobile phone via Bluetooth before testing incoming calls.
Was this article helpful?
