My name is Antonio and I'm starting with simple project.
I'm working on school project and the task is to connect Arduino with six push button.
Every button will be in the one part of teddy bear (hand, leg, ear).
Push button is sending signal to Arduino and then I need to play via Arduino and speaker which part of the body it is.
If someone press right leg then on speaker we need to hear "Right leg."
Hope everyone understand task.
Any Arduino would do the job. Selecting a fysically small version might be interesting. Power consumption might be interesting.
Buttons... The fycical aspect us likely the most imoortant aspect.
The you must match the physical construction of the push button with the unknown supporting material! Designing things have to be done one step at a time!
You didn't say, but if you've not done anything like this, it will go easier if you proceed step by step.
Use any Arduino board and perfect a sketch that prints "you pushed on the kidney" or whatever is appropriate, for each of six pushbuttons of any kind.
That will be most of the logic for your toy and will be easier to get working before you start on the audio, before you start on the final mechanical concept.
If you use the DF player, start by getting example code to work, code you didn't write or mess with.
Combining working parts is better than having the hole thing inside a teddy bear doing nothing at all.
This is my first Arduino project so I'm thinking step by step.
First idea is to connect six buttons and maybe use LED just to have some indication (even I can use monitoring in Arduino with message like "Button 1 - pressed."
I'd second the suggestion from @PaulRB (unless getting started with Arduino is your primary motive, rather than getting the toy made in a short time).
Using the link to the module's datasheet provided by @2112 I'd suggest the simplest version, with only five buttons. You'll find its schematic by scrolling about a third down. And I think instead of a miniature speaker you might need to consider an earpiece.
Don't know if that leaves Antonio confused, but I am? He wants an Arduino solution, which I understood you recommended from your link in post #8. But now you don't?
Based largely on Antonio’s last post but also on a guess as to his skill level, my suggestion would be a Uno plus an inexpensive DfR MP3 Mini Player module. He could use the latter either for a no Uno, resistor-based project, or successively less simple Uno stuff.
Project is at the moment in the last phase.
I have problem with some communication.
For this, I bought joy-it arduino mega 2560 rev3, I have DfR MP3 Mini Player module and speaker.
Problem is in some communication. For test, I worked with Arduino Uno and all worked well. Now I change to joy it and I have problem..
Code here:
#include "DFRobotDFPlayerMini.h"
#include <SoftwareSerial.h>
#include "Arduino.h"
#define rxPin 10
#define txPin 11
// Set up a new SoftwareSerial object
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
#define FPSerial softSerial
// ============= PINS SETUPS =============
// buttons
const int btn_left = 2;
const int btn_right = 3;
// leds
const int led_left = 6;
const int led_right = 7;
// ============= OTHER =============
// state ON/OFF of buttons
int btn_left_state = 0;
int btn_right_state = 0;
int btn_left_state_prev = 0;
int btn_right_state_prev = 0;
int led_left_state = 0;
int led_right_state = 0;
unsigned long time = 0; // the last time the output pin was toggled
unsigned long debounce = 200UL;
DFRobotDFPlayerMini myDFPlayer;
void setup() {
// Define pin modes for TX and RX
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
// Set the baud rate for the SoftwareSerial object
mySerial.begin(9600);
// LEDs -> Outputs
pinMode(led_left, OUTPUT);
pinMode(led_right, OUTPUT);
// Buttons -> Inputs
pinMode(btn_left, INPUT);
pinMode(btn_right, INPUT);
FPSerial.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(FPSerial, /*isACK = */true, /*doReset = */true)) { //Use serial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(30); //Set volume value. From 0 to 30
}
void loop() {
// read the state of buttons
btn_left_state = digitalRead(btn_left);
btn_right_state = digitalRead(btn_right);
// left button
if (btn_left_state == HIGH) {
myDFPlayer.play(1);
digitalWrite(led_left, HIGH);
delay(2800);
digitalWrite(led_left, LOW);
}
// right button
if (btn_right_state == HIGH) {
myDFPlayer.play(2);
digitalWrite(led_right, HIGH);
delay(2800);
digitalWrite(led_right, LOW);
}
}
Problem/Error next:
C:\Users\Antonio\Dropbox (Old)\PC (2)\Downloads\CAR_Arduino\CAR_Arduino\prototype\prototype.ino: In function 'void setup()':
C:\Users\Antonio\Dropbox (Old)\PC (2)\Downloads\CAR_Arduino\CAR_Arduino\prototype\prototype.ino:10:18: error: 'softSerial' was not declared in this scope #define FPSerial softSerial
^
C:\Users\Antonio\Dropbox (Old)\PC (2)\Downloads\CAR_Arduino\CAR_Arduino\prototype\prototype.ino:64:3: note: in expansion of macro 'FPSerial'
FPSerial.begin(9600);
^~~~~~~~
C:\Users\Antonio\Dropbox (Old)\PC (2)\Downloads\CAR_Arduino\CAR_Arduino\prototype\prototype.ino:10:18: note: suggested alternative: 'mySerial' #define FPSerial softSerial
^
C:\Users\Antonio\Dropbox (Old)\PC (2)\Downloads\CAR_Arduino\CAR_Arduino\prototype\prototype.ino:64:3: note: in expansion of macro 'FPSerial'
FPSerial.begin(9600);
^~~~~~~~
exit status 1
Compilation error: 'softSerial' was not declared in this scope