The JDY-40 can be configured using AT commands sent over its serial port. To enter AT mode, hold the SET pin low (connect to GND) while powering up the module. Release SET after power-on. Then, using the Arduino’s SoftwareSerial library (to avoid interfering with the hardware serial used for programming), you can send commands like:
| JDY-40 Pin | Arduino Pin | | :--- | :--- | | VCC | 3.3V | | GND | GND | | TX | Pin 2 (SoftwareSerial) | | RX | Pin 3 (via voltage divider) |
const int buttonPin = 4; int lastState = LOW;