Programming in C Create a program which turns your Arduino i
Programming in C.
Create a program which turns your Arduino into a light based electronic instrument. The program should play music based on the amount of light hitting the optical sensor. There should be a way to capture particularly pleasing tones and play those tones back in the order they are captured.
The program must utilize the following :
• An array to hold the stored tones
• A function : void read_buttons( int *sw1, int *sw2, int *sw3, int *sw4) to read and store the state of the four buttons on the board
• A function playback( notes[] ) which plays back the notes stored
• A function clear_playlist( *notes) which clears the stored tones
• A function tone_value() which generates a tone based on the current state of the optical sensor
• The possible tones should span the range of human hearing
Solution
#include<iostream>
#include<conio.h>
using namespace std;
// Class Declaration
class prime
{
//Member Varibale Declaration
int a,k,i;
public:
prime(int x)
{
a=x;
}
// Object Creation For Class
void calculate()
{
k=1;
{
for(i=2;i<=a/2;i++)
if(a%i==0)
{
k=0;
break;
}
else
{
k=1;
}
}
}
void show()
{
if(k==1)
cout<<\"\ \"<<a<<\" is Prime Number.\";
else
cout<<\"\ \"<<a<<\" is Not Prime Numbers.\";
}
};
//Main Function
int main()
{
int a;
cout<<\"Enter the Number:\";
cin>>a;
// Object Creation For Class
prime obj(a);
// Call Member Functions
obj.calculate();
obj.show();
getch();
return 0;
}

