r/ArduinoHelp • • Mar 22 '25

Need help with selecting and playing mp3 files with df player and 4x4 keypad.

3 Upvotes

Hello, I am quite new to arduino and I am working on a birthday present for a good friend of mine and I am getting quite desperate because I just can't figure out how to play more than 9 different sound files with the keypad and the dfplayer module.

For reference my keypad is 4x4 rows (row 1: 123A, row 2: 456B, row 3: 789C, row 4: \\\*0#D).

What I would like to do is quite simple I want to type in a number between 1-999 (there's actually only 200 different files but you get the idea), confirm with the "#" key and then just play the corresponding mp3.

Preferable, I would like it to just play, for example, the 68th file that was added to the SD card when I type in 68# and play the file that was added to the SD 174th when I type in 147# because that's how I have been doing it with my 1-9 numbers set-up and I like it because it saves me from having to specifically name the files and reference them in the code.

I have been trying to get it to work for hours now and I am quite exasperated, so I would really appreciate it if somebody could help me out with a working code so I can finish up this birthday present without having to pull an all-nighter trying to figure it out myself.

This is the code I am working with

`1 #include "Keypad.h"`

`2`

`3 #include "Arduino.h"`

`4`

`5 #include "SoftwareSerial.h"`

`6`

`7 #include "DFRobotDFPlayerMini.h"`

`8`

`9`

`10`

`11 SoftwareSerial mySoftwareSerial(10, 11); // RX, TX`

`12`

`13 DFRobotDFPlayerMini myDFPlayer;`

`14`

`15`

`16`

`17`

`18 const byte ROWS = 4; //four rows`

`19`

`20 const byte COLS = 4; //four columns`

`21`

`22`

`23`

`24 char keys[ROWS][COLS] = {`

`25`

`26 { '1', '2', '3', 'A' },`

`27`

`28 { '4', '5', '6', 'B' },`

`29`

`30 { '7', '8', '9', 'C' },`

`31`

`32 { '*', '0', '#', 'D' }`

`33`

`34 };`

`35`

`36`

`37`

`38 byte rowPins[ROWS] = { 9, 8, 7, 6 }; //connect to the row pinouts of the keypad`

`39`

`40 byte colPins[COLS] = { 5, 4, 3, 2 }; //connect to the column pinouts of the keypad`

`41`

`42`

`43`

`44 Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);`

`45`

`46`

`47`

`48 String keypadKeys = "1234567890*#ABCD";`

`49`

`50`

`51`

`52 void setup() {`

`53`

`54`

`55`

`56 mySoftwareSerial.begin(9600);`

`57`

`58 Serial.begin(9600);`

`59`

`60`

`61`

`62 if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.`

`63`

`64 Serial.println(F("Unable to begin:"));`

`65`

`66 Serial.println(F("1.Please recheck the connection!"));`

`67`

`68 Serial.println(F("2.Please insert the SD card!"));`

`69`

`70 while (true)`

`71`

`72 ;`

`73`

`74 }`

`75`

`76`

`77`

`78 myDFPlayer.volume(10); //Set volume value. From 0 to 30`

`79`

`80 }`

`81`

`82`

`83`

`84 void loop() {`

`85`

`86`

`87`

`88 char keyPressed = keypad.getKey();`

`89`

`90`

`91`

`92 if (keyPressed) {`

`93`

`94 Serial.println(keyPressed);`

`95`

`96 int sampleIndex = 1 + keypadKeys.indexOf(keyPressed); //Convert pressed key (1234567890*#ABCD) to sample index (1-16)`

`97`

`98 Serial.println(sampleIndex);`

`99`

`100 myDFPlayer.play(sampleIndex);`

`101`

`102 } //Play the chosen mp3`

`103`

`104 }`

I have never drawn a diagram (I am really quite new to this), but the 4x4 Keypad is connected on pins 2, 3, 4, 5, 6, 7, 8 and 9 on the Arduino Uno and the dfplay and the speaker are connected exactly like in [this picture](https://europe1.discourse-cdn.com/arduino/original/4X/d/d/c/ddc25cafbd4715b79b1eeb884a243768d2224d26.jpeg) (both the sound and the keypad work just fine, it's only that I cannot figure out how to make 3 digits work).


r/ArduinoHelp • • Mar 17 '25

Needing help with my auto-watering system :)

3 Upvotes

Hello, I am building an auto watering system using Arduino UNO and Adafruit components. I have a capacitative soil sensor that powers an underwater motor but the but doesn't reliably stay powered, even though the power still runs through it sometimes?

Here are the parts I am using:

Arduino UNO

Submersible Water Pump: https://www.adafruit.com/product/4546

Soil Sensor: https://www.adafruit.com/product/4026

I've had the Arduino for about a year and just purchased the other parts. The system works by checking if the capacitance amount of the dirt is lower than the 'dry' capacitance (500). When it is dry, it outputs high voltage through digital pins 2 and 5, turning on the blue led and the submersible motor at the same time.

When I power the Arduino, it turns on the blue light indicating the soil is dry, however, the motor does not function unless I switch the wire powering it from digital pin 5 to the 5 volt and back, which somehow makes it work. When it is working, it seems to randomly disconnect after a couple times the capacitance goes below and above 500.

I've tried replacing the wires that power the motor to no luck. I also stripped the wire to hopefully give it better access to power. When I replace the motor with a light, it powers the light without issue. I've also switched out which pin powers the motor, trying both digital pins 4 and 5. I've come down to two possible solutions I can think of:

  1. Order another (different) submersible water pump and hope that the same issue does not occur or

  2. solder the water pump wiring to another wire to give it better conductivity with the breadboard

I'm just a beginner to arduino, this is my first big project, so any and all advice and information I can get regarding this would be wonderful. Thank you for your time and helping me make this project come to life :)

Also, here is my code that runs on the Arduino:

#include "Adafruit_seesaw.h"

Adafruit_seesaw ss;

// temperature stats
const int tempMedian = 21; // ideal range for greek oregano : 15 - 27
const int tempDiff = 6; 
const int tempCritDiff = tempDiff * 2.5; // plant cannot survive in this temp
// moisture stats
const int dry = 400; // when the cap is < dry , the dirt is DRY!

#define REDLIGHT 3
#define BLUELIGHT 2
#define MOTOR 4

void setup() {
  Serial.begin(115200);

  Serial.println("seesaw Soil Sensor example!");
  
  if (!ss.begin(0x36)) {
    Serial.println("ERROR! seesaw not found");
    while(1) delay(1);
  } else {
    Serial.print("seesaw started! version: ");
    Serial.println(ss.getVersion(), HEX);
  }

  pinMode(REDLIGHT,OUTPUT);
  pinMode(BLUELIGHT,OUTPUT);
  pinMode(MOTOR,OUTPUT);

}

void loop() {
  float tempC = ss.getTemp();
  uint16_t capread = ss.touchRead(0);
  
  // report temp 
  int diff = abs(tempC - tempMedian);
  Serial.print("Distance from comfortable temperature: ");
  Serial.print(diff); Serial.println("*C");

  // report base temperature & capacitative
  Serial.print("Temperature: "); Serial.print(tempC); Serial.println("*C");
  Serial.print("Capacitive: "); Serial.println(capread);
  
  // critical temperatures reached - is it too hot or too cold ?
  if (diff > tempCritDiff) {
    // Redlight never turns off once on unless manually reset !
    digitalWrite(REDLIGHT,HIGH); 
  }

  // is the dirt dry? 
  if (capread < dry) {
    digitalWrite(BLUELIGHT,HIGH); // blue is on when the plant needs watering
    digitalWrite(MOTOR,HIGH);
  } else {
    digitalWrite(BLUELIGHT,LOW);
    digitalWrite(MOTOR,LOW)
  }
  // wait to run again
  delay(500);
}


#include "Adafruit_seesaw.h"


Adafruit_seesaw ss;


// temperature stats
const int tempMedian = 21; // ideal range for greek oregano : 15 - 27
const int tempDiff = 6; 
const int tempCritDiff = tempDiff * 2.5; // plant cannot survive in this temp
// moisture stats
const int dry = 400; // when the cap is < dry , the dirt is DRY!


#define REDLIGHT 3
#define BLUELIGHT 2
#define MOTOR 4


void setup() {
  Serial.begin(115200);


  Serial.println("seesaw Soil Sensor example!");
  
  if (!ss.begin(0x36)) {
    Serial.println("ERROR! seesaw not found");
    while(1) delay(1);
  } else {
    Serial.print("seesaw started! version: ");
    Serial.println(ss.getVersion(), HEX);
  }


  pinMode(REDLIGHT,OUTPUT);
  pinMode(BLUELIGHT,OUTPUT);
  pinMode(MOTOR,OUTPUT);


}


void loop() {
  float tempC = ss.getTemp();
  uint16_t capread = ss.touchRead(0);
  
  // report temp 
  int diff = abs(tempC - tempMedian);
  Serial.print("Distance from comfortable temperature: ");
  Serial.print(diff); Serial.println("*C");


  // report base temperature & capacitative
  Serial.print("Temperature: "); Serial.print(tempC); Serial.println("*C");
  Serial.print("Capacitive: "); Serial.println(capread);
  
  // critical temperatures reached - is it too hot or too cold ?
  if (diff > tempCritDiff) {
    // Redlight never turns off once on unless manually reset !
    digitalWrite(REDLIGHT,HIGH); 
  }


  // is the dirt dry? 
  if (capread < dry) {
    digitalWrite(BLUELIGHT,HIGH); // blue is on when the plant needs watering
    digitalWrite(MOTOR,HIGH);
  } else {
    digitalWrite(BLUELIGHT,LOW);
    digitalWrite(MOTOR,LOW)
  }
  // wait to run again
  delay(500);
}

Here are some pictures of my setup


r/ArduinoHelp • • Mar 14 '25

Arduino crystal display

3 Upvotes

Im just starting with arduino and have ran into complications with the crystal display im bot sure wether my wiring, coding or display is the problem. Im attempting to have the button display its state on the screen any help would be appreciated. When i press the button nothing seems to happen and when i hold down the blue wire it starts appearing as normal


r/ArduinoHelp • • Mar 06 '25

Neopixels

Post image
3 Upvotes

I saw someone wire their LEDs like this so I did as well. I didn’t connect it to an external battery source, but it connected the arduino to a battery pack. Only the first LED lit up. Any help?


r/ArduinoHelp • • Feb 15 '25

Can I use this power supply for my 12v gearbox motor?

Post image
3 Upvotes

What confuses me is that there is no 12v pin, but it does say 12v on the board meaning it’s a 12v power supply, no?


r/ArduinoHelp • • Feb 04 '25

Help replicating this design with a different board! Look

Thumbnail
gallery
3 Upvotes

Hello I have a board that I want to be able to “push” its buttons remotely and I’ve been following this as my guide to doing so but I’m using a new board that I’ve never used before it’s a [NodeMCU 1.0 (ESP-12E Module)] and I don’t know if I’m just reading its example code wrong or if I also set up my board wrong in correlation to the code but could anyone help me figure this out? Thank you!


r/ArduinoHelp • • Jan 02 '25

L293D not powering Arduino

Thumbnail
gallery
3 Upvotes

This is a project my group and I did during our introduction to engineering course. I was the one who took the final result home. This isn’t the first time that it didn’t power the arduino but it was a simple fix because the jumper was not on properly. Now it’s suddenly died out on me again and I don’t know why the power isn’t transferring this time. Thank you. Please request any visuals if needed because I know the video is sloppy. Also ignore any cut wires.


r/ArduinoHelp • • Dec 22 '24

200€ budget to get me some Arduino stuff as a Christmas present.🎄🎁

3 Upvotes

Hi everyone,

My girlfriend gives me a 200€ budget to get me some Arduino stuff as a Christmas present.🎄🎁🥹

I always wanted to have something and start some projects. I don't have a specific idea what I want to do right now, but here and there, something always comes to my mind. So far I'm a tech guy and love doing stuff with electronics. I'm also a learned electrician. So I have spare parts of old tech and stuff here, which I could also use for the projects.

I thought of getting 2 different kits in the range of 200€ together.

Or 1 kit and some standalone boards and parts.

What should I go for, if I want to be able to have access to a variety of features? What would you guys recommend me, as a Arduino beginner?


r/ArduinoHelp • • Nov 30 '24

Female connectors too short

Thumbnail
gallery
3 Upvotes

Hi i bought the official arduino kit and I’m supposed to add the header pins to the servo motor but they are too short to insert into the breadboard. Should I just try getting rid of the black plastic? Thanks! (Also i tried to put the short end into the servo motor but it’s too short)


r/ArduinoHelp • • Nov 06 '24

Is this going to be a problem?

Post image
3 Upvotes

Hi just bought a kit and one of the pins is bent, can I just bend it back in place? (It’s an LCD display)


r/ArduinoHelp • • Nov 06 '24

How can I connect these? Uno R3, module relay, 12v pump and 12v power. Or I must use another way to have an external power for the module relay?

Thumbnail
gallery
3 Upvotes

r/ArduinoHelp • • Oct 19 '24

Windows 11 - unable to properly install drivers

3 Upvotes

When I install Silicon Labs CP210x USB to UART Bridge drivers, they appear to get installed, but do not show up, aand no ports are available neither in Arduino IDE nor in device manager at all (wtf?).

I tried "Add legacy hardware" procedure, and add ports there with the driver, but it did not work.

What could be the problem?


r/ArduinoHelp • • Oct 12 '24

Arduino behaves differently when disconnected from computer.

Thumbnail
gallery
3 Upvotes

This is my first arduino project and I'm experiencing an issue with the way the arduino works plugged to my computer and running on a battery. Thr arduino is working with an acceloremeter, a relay, two motors and a buck converter.

When the arduino is plugged to my computer it behaves the way it's supposed to. The arduino has an accelerometer that once it detects Y > 3 it activates the motor. This happens just fine when connected to my computer. The motor is activated only after the threshold is met.

When the arduino is disconnected, however, the motor is activates regardless of the orientation. I'm clueless on why this might be happening.

I don't think the problem lies in the code since, like I mentioned the arduino works just fine when plugged to my computer.

Any help is deeply appreciated.


r/ArduinoHelp • • Sep 18 '24

Trouble getting script to upload

3 Upvotes

My first microcontroller. I bought the Arduino Uno R3 off of Amazon. Trying to get it to connect to my windows 10 laptop was a challenge. I used Atmel flip to flash the mega16u2, used the project 15 hex file. Now my computer and Arduino IDE recognize the controller, but I keep getting an error "avrdude, programmer not responding/ not in sync." The rx led will flash when I try to upload, but the tx stays off. The other weird thing I noticed, and I'm not sure if this is normal, but the L led will dim and brighten as I move my hand closer and further away from it. I'm happy to provide more information. Thank you for reading, and anything might help!


r/ArduinoHelp • • Jul 22 '24

Using a stepper motor

Post image
3 Upvotes

Would i be able to power this stepper motor directly from my arduino mega? In theroy i should be able to put the power pin directly to the 3v power pin on the mega board right?


r/ArduinoHelp • • Apr 23 '24

Sim800c module, LED(status indicator) not lighting up

Post image
3 Upvotes

When I first researched about the sim800c module, I expected the status indicator to blink, but the only thing I saw was the power indicator lighting.(picture)

I have an 3.7V external battery connected to the “5V pin” and the “GND pin” on the sim800c.

The TXD pin is connected to the pin 3(Arduino) while the RXD pin is connected to the pin 2(Arduino)

I also read that the PWX pin should be connected to the GND pin(Arduino ), so I also did that.

When I test the module anyways with Arduino IDE, the Serial Monitor does not respond. I have tried with multiple codes from the internet which have worked for others.

I would like to get help with getting the status indicator to work, so I can send sms with my module.


r/ArduinoHelp • • Jun 13 '23

I need help, arduino nano not uploading

Thumbnail
gallery
3 Upvotes

So I have these arduino uno and nano, the arduino uno works perfectly but the nano doesn't, (these are from aliexpress, and I had to burn a new bootloader when they came in a few moths ago and worked fine), now I'm currently on a project and when I try compiling it says that there is no errors, but when I pressupload, the code it doesn't work, it just says "can't set com-state for..." I'm loosing my mind and I dk t know what to do anymore


r/ArduinoHelp • • Jun 12 '23

Help with my school project

3 Upvotes

Hello!

Recently I have been trying to make a project which consists on making a scarecrow that detects sounds and emits noises from a speaker and moves his "arms" in a way to scare birds and other animals away. The arms will be moved by a motor which would be connected to a battery which is charged with a solar panel.

Im doing this with my colleagues for our final project and we are kind of stuck in the code process of the whole project. We still need to draw the circuit but our objective is:

Having the sound sensor detect a sound and the LED turns on. When this happens, it should make the speaker emit the sound we choose and, at the same time, make the motor run and move the arms.

There will be a button to turn on and off the circuit since its not that big and our objective is for it to be enviromental friendly and appropriate to small gardens at home.

Can anyone please help us out in what we need to do with the code process with arduino? And will only 1 arduino be enough? We just learned how to use arduino so we're kind of in the blank here that's why Im asking for help but we really liked the idea and wanted to make this school year different from the other.

Edit: And yes, we searched for videos that make our ideas work but only alone. For example, we searched on how to make the sound sensor but we still need to test it out but we want help to make everything work simultaneously


r/ArduinoHelp • • Mar 11 '23

need some help with an encoder. i saved this encoder from the trash at my work, and i want to use it for an arduino project. I have no idea where to begin though and how to connect it. any ideas?

Thumbnail
gallery
3 Upvotes

r/ArduinoHelp • • Oct 31 '22

Need help programming this using a mpu6050 and arduino uno

Post image
3 Upvotes

r/ArduinoHelp • • Jul 30 '22

Bedroom security system

3 Upvotes

Hello!

I had an idea for a security system for my bedroom using d1 mini's. But I have no idea how to implement it.

I want it to be outside my door and have an nfc card reader. The nfc card will have some sort of user ID in it, the d1 mini will send this ID to the server (this is where my problem is) and check whether or not it's a real ID and if it has access. But I don't know where that data will be stored and how a to access it.

In a perfect world the arduino IOT platform would be able to have text files and I would store the data there.

Maybe I can write the program in c++ and store the data on a file on my computer? But I would rather it be an IOT platform so that it has a mobile dashboard.

Any help would be appreciated.

Edit: grammer bot is jerk


r/ArduinoHelp • • Jul 01 '22

Anyone knows a dowloadable software for arduino simulations?

3 Upvotes

r/ArduinoHelp • • Jun 03 '22

Automated Agricultural Arm Height.

3 Upvotes

Hi! Hope you're having a great day!

I really need help with an agricultural project, I want to automate the height of an fertilizer arm that normally its regulated with buttons by an operator (it's mounted in a tractor moving alongside the crop); I'm using a capacitive proximity sensor that detects the top part of the plant (the fertilizer nozzle it's just behind the sensor), all the system its controlled by an Arduino.

The control logic it's quite simple:

If the sensor it's ON, move the arm UP. If the sensor it's OFF, move the arm DOWN.

It's an oscillation movement of the arm, regulating itself to

fertilize just the top of the plant.

I need help with the code, diagram, additional components or anything that would help achieve my goal.

Thank you very much!


r/ArduinoHelp • • May 15 '22

Assignment: Make a button that when pressed, turns off an LED and turns another on. There should be at least 3 LEDs.

3 Upvotes

ive a roadblock. i have tried some things but I still don't know how to use the last button state for each.

int BUTTON_PIN = 8;

int LED_PIN1 = 3;

int LED_PIN2 = 4;

int LED_PIN3 = 5;

int ledState = HIGH;

int ledState2 = LOW;

int ledState3 = LOW;

int lastButtonState;

int currentButtonState;

void setup() {

pinMode(BUTTON_PIN, INPUT);

pinMode(LED_PIN1, OUTPUT);

currentButtonState = digitalRead(BUTTON_PIN);

}

void loop() {

lastButtonState = currentButtonState;

currentButtonState = digitalRead(BUTTON_PIN);

if(lastButtonState == HIGH && currentButtonState == LOW) {

ledState = !ledState;

digitalWrite(LED_PIN1, ledState);

digitalWrite(LED_PIN2, ledState2);

digitalWrite(LED_PIN3, ledState3);

}

}