PIYUSH_K_SINGH
Published © GPL3+

Mechanical Musical Arm

A musical arm used to play 7 'sur' using only three fingers!

AdvancedShowcase (no instructions)661
Mechanical Musical Arm

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×2
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×1
Pmod SD
Digilent Pmod SD
×1
Real Time Clock (RTC)
Real Time Clock (RTC)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1
RobotGeek Sensor Shield
RobotGeek Sensor Shield
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Digilent Screwdriver
Digilent Screwdriver
9V DC Battery Connector

Story

Read more

Schematics

Master_Slave_Connection

To connect two Arduinos.
Ms rdz7qfxrol 8hylsahagf

Code

MASTER_CODE

Arduino
To control Master Arduino!
#include<Wire.h>



const int ProxSensor1=8;
const int ProxSensor2=9;
const int ProxSensor3=10;

int buzz=11;
int i;
int pin[8]={0,1,2,3,4,5,6,7};



 
void setup() {  

   Wire.begin();              
  
  pinMode(buzz, OUTPUT);   
  
for(i=0;i<8;i++)
{ pinMode(pin[i],OUTPUT);
  }
  
 
  pinMode(ProxSensor1,INPUT);
  pinMode(ProxSensor2,INPUT);
  pinMode(ProxSensor3,INPUT);
  Serial.begin(9600);
}

void loop() {

Wire.beginTransmission(12);
  
  if((digitalRead(ProxSensor1)==HIGH) && (digitalRead(ProxSensor2)==LOW) && (digitalRead(ProxSensor3)==LOW)) {     
  tone(buzz,240,50);
  pin[0]=HIGH;
  pin[7]=LOW;
    Serial.println("saa");
    Wire.write(1);
   
  }



  


  
  else if((digitalRead(ProxSensor1)==LOW) && (digitalRead(ProxSensor2)==HIGH) && (digitalRead(ProxSensor3)==LOW))
  {
    tone(buzz,270,50);
    pin[1]=HIGH;
  pin[7]=LOW;
    
    Serial.println("re"); //set the  YELLOW LED on
    Wire.write(2);
  }



  
   else if((digitalRead(ProxSensor1)==LOW) && (digitalRead(ProxSensor2)==LOW) && (digitalRead(ProxSensor3)==HIGH))      
  {
    tone(buzz,300,50);
    pin[2]=HIGH;
  pin[7]=LOW;
     
    Serial.println("Ga");
    Wire.write(3);
  }

  
  else if((digitalRead(ProxSensor1)==HIGH) && (digitalRead(ProxSensor2)==HIGH) && (digitalRead(ProxSensor3)==LOW))
  {
    tone(buzz,320,50);
    pin[3]=HIGH;
  pin[7]=LOW;
    Serial.println("MA");
    Wire.write(4);
  }
  
  

    else if((digitalRead(ProxSensor1)==HIGH) && (digitalRead(ProxSensor2)==LOW) && (digitalRead(ProxSensor3)==HIGH))
  {
    tone(buzz,360,50);
    pin[4]=HIGH;
  pin[7]=LOW;
    Serial.println("PA");
    Wire.write(5);
  }



  else if((digitalRead(ProxSensor1)==LOW) && (digitalRead(ProxSensor2)==HIGH) && (digitalRead(ProxSensor3)==HIGH))
  {
    tone(buzz,400,50);
    pin[5]=HIGH;
  pin[7]=LOW;
    Serial.println("DHA");
    Wire.write(6);
  }

 else if((digitalRead(ProxSensor1)==HIGH) && (digitalRead(ProxSensor2)==HIGH) && (digitalRead(ProxSensor3)==HIGH))
  {
    tone(buzz,450,50);
    pin[6]=HIGH;
  pin[7]=LOW;
    Serial.println("NI");
    Wire.write(7);
  }
  
else{
  for(int i=0;i<8;i++)
  { pin[i]=LOW;
  }
 pin[7]=HIGH;
} 

}

SLAVE_CODE

Arduino
To control Slave Arduino!
/* SD card datalogger

 This example shows how to log data from TEMPRATURE AND HUMIDITY SENSOR,
 to an SD card using the SD library.

 The circuit:
 * analog sensors on analog ins 0, 1, and 2
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 10 (for MKRZero SD: SDCARD_SS_PIN)

by PIYUSH KUMAR SINGH
 

 */

#include <SPI.h>
#include <SD.h>

#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68

// Convert normal decimal numbers to binary coded decimal

int x;

byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}








const int chipSelect = 10;




void setup() {
   
  Serial.begin(9600);
  Wire.begin(12); 

  Wire.onReceive(receiveEvent);
 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");
  

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}


void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}






void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}












void writeTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);

  String TIMEString="";
  File TIMEFile = SD.open("IR.txt", FILE_WRITE);
  

TIMEString += "TIME:   ";
TIMEString += String(hour, DEC);
TIMEString += ":";


if (minute<10)
  {
    TIMEString += "0";
    
  }

  TIMEString += String(minute, DEC);
 
 TIMEString += ":";


 if (second<10)
  {
    TIMEString += "0";
  }
  TIMEString += String(second, DEC);


TIMEString += "  ";

TIMEString += String(dayOfMonth, DEC);
TIMEString += "/";
TIMEString += String(month, DEC); 
 TIMEString += "/";
 TIMEString += String(year, DEC); 
  
  TIMEString +=" Day of week: ";




  switch(dayOfWeek){
  case 1:
    TIMEString +="Sunday";
    break;
  case 2:
    TIMEString +="Monday";
    break;
  case 3:
    TIMEString +="Tuesday";
    break;
  case 4:
    TIMEString +="Wednesday";
    break;
  case 5:
    TIMEString +="Thursday";
    break;
  case 6:
    TIMEString +="Friday";
    break;
  case 7:
    TIMEString +="Saturday";
    break;
  }

// if the file is available, write to it:
  if (TIMEFile) {
    TIMEFile.println(TIMEString);
    TIMEFile.close();
    // print to the serial port too:
    Serial.println(TIMEString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening IR.txt");
  }
}

void receiveEvent(int bytes) {
  x = Wire.read();    // read one character from the I2C
}





void loop() {
 String TIME = "";
 
 switch(x)
 { 
  case 1: { writeTime();
            TIME += "SAA";
            break;
                 }

  case 2: { writeTime();
            TIME += "RE";
            break;
                 }

 case 3: { writeTime();
            TIME += "GAA";
            break;
                 }

 case 4: { writeTime();
            TIME += "MAA";
            break;
                 }                

 case 5: { writeTime();
            TIME += "PAA";
                 }   
 case 6: { writeTime();
            TIME += "DHA";
            break;
                 }  

  case 7: { writeTime();
            TIME += "NI";
            break;
                 } 

default :  { writeTime();
            TIME += "empty";
            break;
                 } 


 }


 File mainFile = SD.open("song.txt", FILE_WRITE);
  

  // if the file is available, write to it:
  if (mainFile) {
    mainFile.println(TIME);
    mainFile.close();
    // print to the serial port too:
    Serial.println(TIME);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening IR.txt");
  }

                 
}

Credits

PIYUSH_K_SINGH

PIYUSH_K_SINGH

1 project • 0 followers

Comments

Add projectSign up / Login