India Automation Challenge 2021
OR
Students who receive STEM education become critical thinkers, have a higher level of science literacy and are more likely to be innovators. Innovation is the key to sustaining the economy. A solid knowledge base in STEM fields is essential for innovation and science literacy. That's why we have decided to make some interesting projects which will help children to learn the better and practical way. To admin/upload different songs, format your SD card with either FAT16 or FAT32. As Arduino mega can't read MP3 files directly, need to convert the file into a ".wav" file. For this -- visit "https://audio.online-convert.com/convert-to-wav" and convert any .mp3 into .wav file as per recommended settings: bit resolution: 8 Bit sampling rate: 32000 Hz audio channel: stereo Once completed, copy the song to the SD card using a card reader and insert it into the microSD card module.
1. Arduino Mega x 1 2. Tactile push Button x 26 3. Copper Wire 4. 3.7v Rechargeable Battery x 2 5. 8-ohm Speaker 6. SD Card Module x 1 7. 8gb SD card
1. Arduino IDE
The Arduino MEGA 2560 is designed for projects that require more I/O lines, more sketch memory, and more RAM. With 54 digital I/O pins, 16 analog inputs this is the best hardware that meets our requirements. We also used the Micro SD card module which helps to read data from sd cards. 8-ohm speaker for clear sound and 3.7v rechargeable battery for long-duration playtime.
Micro SD Card Module has six pins, 2 for power( VCC, GND) and 4 pins for the SPI communication. Gnd to GND MISO to D50 (MISO) SCK to D52 (SCK) MOSI to D51 (MOSI) CS to D53 (SS) +5 to +5V Speaker - D10
#include "SD.h" //Lib to read SD card #define SD_ChipSelectPin 53 //Chip select is pin number 4 const int A = 8; void setup(){ //pinMode(button, INPUT); music.setVolume(7); // 0 to 7. Set volume level void loop() while (digitalRead(B)==LOW) //Button 1 Pressed while (digitalRead(C)==LOW) //Button 1 Pressed while (digitalRead(D)==LOW) //Button 1 Pressed while (digitalRead(E)==LOW) //Button 1 Pressed
#include "TMRpcm.h" //Lib to play auido
#include "SPI.h" //SPI lib for SD card
TMRpcm music; //Lib object is named "music"
const int B = 7;
const int C = 6;
const int D = 5;
const int E = 4;
const int F = 3;
const int G = 2;
const int H = 30;
const int I = 31;
const int J = 32;
const int K = 33;
const int L = 34;
const int M = 35;
const int N = 36;
const int O = 37;
const int P = 38;
const int Q = 39;
const int R = 40;
const int S = 41;
const int T = 42;
const int U = 43;
const int V = 44;
const int W = 45;
const int X = 46;
const int Y = 47;
const int Z = 48;
int button=10;
music.speakerPin = 11; //Auido out on pin 11
Serial.begin(9600); //Serial Com for debugging
pinMode(D, INPUT);
digitalWrite(D,HIGH);
pinMode(A, INPUT);
digitalWrite(A,HIGH);
pinMode(B, INPUT);
digitalWrite(B,HIGH);
pinMode(C, INPUT);
digitalWrite(C,HIGH);
pinMode(E, INPUT);
digitalWrite(E,HIGH);
pinMode(F, INPUT);
digitalWrite(F,HIGH);
pinMode(G, INPUT);
digitalWrite(G,HIGH);
pinMode(H, INPUT);
digitalWrite(H,HIGH);
pinMode(I, INPUT);
digitalWrite(I,HIGH);
pinMode(J, INPUT);
digitalWrite(J,HIGH);
pinMode(K, INPUT);
digitalWrite(K,HIGH);
pinMode(L, INPUT);
digitalWrite(L,HIGH);
pinMode(M, INPUT);
digitalWrite(M,HIGH);
pinMode(N, INPUT);
digitalWrite(N,HIGH);
pinMode(O, INPUT);
digitalWrite(O,HIGH);
pinMode(P, INPUT);
digitalWrite(P,HIGH);
pinMode(Q, INPUT);
digitalWrite(Q,HIGH);
pinMode(R, INPUT);
digitalWrite(R,HIGH);
pinMode(S, INPUT);
digitalWrite(S,HIGH);
pinMode(T, INPUT);
digitalWrite(T,HIGH);
pinMode(U, INPUT);
digitalWrite(U,HIGH);
pinMode(V, INPUT);
digitalWrite(V,HIGH);
pinMode(W, INPUT);
digitalWrite(W,HIGH);
pinMode(X, INPUT);
digitalWrite(X,HIGH);
pinMode(Y, INPUT);
digitalWrite(Y,HIGH);
pinMode(Z, INPUT);
digitalWrite(Z,HIGH);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}
music.quality(0);
}
{
while (digitalRead(A)==LOW) //Button 1 Pressed
{
music.play("A.wav"); //Play song 1 from 33rd second
music.setVolume(7);
}
{
music.play("B.wav"); //Play song 2 from 33rd second
}
{
music.play("C.wav"); //Play song 2 from 33rd second
}
{
music.play("D.wav"); //Play song 2 from 33rd second
}
{
music.play("E.wav"); //Play song 2 from 33rd second
}
while (digitalRead(F)==LOW) //Button 1 Pressed
{
music.play("F.wav"); //Play song 2 from 33rd second
}
while (digitalRead(G)==LOW) //Button 1 Pressed
{
music.play("G.wav"); //Play song 2 from 33rd second
}
while (digitalRead(H)==LOW) //Button 1 Pressed
{
music.play("H.wav"); //Play song 2 from 33rd second
}
while (digitalRead(I)==LOW) //Button 1 Pressed
{
music.play("I.wav"); //Play song 2 from 33rd second
}
while (digitalRead(J)==LOW) //Button 1 Pressed
{
music.play("J.wav"); //Play song 2 from 33rd second
}
while (digitalRead(K)==LOW) //Button 1 Pressed
{
music.play("K.wav"); //Play song 2 from 33rd second
}
while (digitalRead(L)==LOW) //Button 1 Pressed
{
music.play("L.wav"); //Play song 2 from 33rd second
}
while (digitalRead(M)==LOW) //Button 1 Pressed
{
music.play("M.wav"); //Play song 2 from 33rd second
}
while (digitalRead(N)==LOW) //Button 1 Pressed
{
music.play("N.wav"); //Play song 2 from 33rd second
}
while (digitalRead(O)==LOW) //Button 1 Pressed
{
music.play("O.wav"); //Play song 2 from 33rd second
}
while (digitalRead(P)==LOW) //Button 1 Pressed
{
music.play("P.wav"); //Play song 2 from 33rd second
}
while (digitalRead(Q)==LOW) //Button 1 Pressed
{
music.play("Q.wav"); //Play song 2 from 33rd second
}
while (digitalRead(R)==LOW) //Button 1 Pressed
{
music.play("R.wav"); //Play song 2 from 33rd second
}
while (digitalRead(S)==LOW) //Button 1 Pressed
{
music.play("S.wav"); //Play song 2 from 33rd second
}
while (digitalRead(T)==LOW) //Button 1 Pressed
{
music.play("T.wav"); //Play song 2 from 33rd second
}
while (digitalRead(U)==LOW) //Button 1 Pressed
{
music.play("U.wav"); //Play song 2 from 33rd second
}
while (digitalRead(V)==LOW) //Button 1 Pressed
{
music.play("V.wav"); //Play song 2 from 33rd second
}
while (digitalRead(W)==LOW) //Button 1 Pressed
{
music.play("W.wav"); //Play song 2 from 33rd second
}
while (digitalRead(X)==LOW) //Button 1 Pressed
{
music.play("X.wav"); //Play song 2 from 33rd second
}
while (digitalRead(Y)==LOW) //Button 1 Pressed
{
music.play("Y.wav"); //Play song 2 from 33rd second
}
while (digitalRead(Z)==LOW) //Button 1 Pressed
{
music.play("Z.wav"); //Play song 2 from 33rd second
}
}