Blogger news

Friday, 27 June 2014

Microcontroller code for dot matrix

ORG 00H
MOV P3,#00000000B     
MOV P1,#00000000B
        
MAIN: MOV P3,#00000000B
      MOV P1,#11111110B
        LCALL DELAY
      MOV P3,#11101111B
      MOV P1,#00000001B
         LCALL DELAY
      MOV P3,#11110111B
      MOV P1,#11111011B
         LCALL DELAY
      MOV P3,#11111011B
      MOV P1,#11110111B
         LCALL DELAY
      MOV P3,#11111101B
      MOV P1,#11101111B
         LCALL DELAY
      MOV P3,#11111110B
      MOV P1,#11011111B
         LCALL DELAY
      MOV P3,#11111001B
      MOV P1,#11011111B
         LCALL DELAY
      MOV P3,#11110111B
      MOV P1,#10111111B
        LCALL DELAY
      MOV P3,#11011111B
      MOV P1,#11111101B
        LCALL DELAY
      MOV P3,#10111111B
      MOV P1,#11110011B
     LCALL DELAY
      MOV P3,#11011111B
      MOV P1,#11101111B
      LCALL DELAY
      SJMP MAIN   
  
    
DELAY: MOV R6,#200d    
HERE: DJNZ R6,HERE

;               ACALL DE1
;               DE1: MOV R2,#2d    
;               HERE1: DJNZ R2,HERE1
      RET
END

Thursday, 26 June 2014

FM and AM modulation using MATLAB code

clc
close all;
clear all;
t=0:0.0001:1;
fm=input('enter the msg frequency');
am=input('enter the msg amplitude');
fc=input('enter carrier signal frequency');
ac=input('enter amplitude of carrier signal');
m=am*cos(2*pi*fm*t);
c=cos(2*pi*fc*t);
x=m.*c;
mod=x+(ac.*c);




%plot
subplot(4,1,1),plot(t,m);
xlabel('time');
ylabel('amplitude');
legend('Message signal m(t)');
title('message');


subplot(4,1,2),plot(t,c);
xlabel('time');
ylabel('amplitude');
legend('Carrier signal c(t)');
title('carrier');

subplot(4,1,3),plot(t,mod);
xlabel('time');
ylabel('amplitude');
legend('Amplitude modulated signal s(t)');
title('mod');


%fm signal

b=(fc-fm)/fm;

modfm=ac.*cos(2*pi*fc.*t + b*sin(2*pi*fm.*t));
subplot(4,1,4)
plot(t,modfm);
xlabel('time---(sec)');
ylabel('amp');
legend('Frequency modulated signal s(t)');
title('FM signal')


%Input and Output:

%enter the msg frequency10
%enter the msg amplitude5
%enter carrier signal frequency100
%enter amplitude of carrier signal5

Wednesday, 25 June 2014

Wave genaretor using MATLAB code

function wave_generator_multiplier=wave_mul(b,g)
cc=length(b);
t=1:1:cc*cc*g;
y=0;
s=1;
z=0
for p=1:g
    for i=1:cc
        for j=1:cc
             as=b(1,i);
             if(as==1)
                     c(1,z+y+j)=1;
             else
                 c(1,z+y+j)=0;
             end
        end
        y=i*cc;
    end
    z=p*cc*cc-cc;
end
plot(t,c);

Calculator using MATLAB code

function CalcGUI
%Function CALCGUI. Integral and Derivative Functions GUI.
% CALCGUI shows the first and second derivatives of the primary functions
% f(x) and g(x) as well as the area from the lower to upper bounds of the
% primary functions.  It also displays the equations of the first and
% second derivatives and the area displayed.

close all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Constant Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

hFigColor=[0.6 0.6 0.6];
xyPanColor=[0 0.7 0];
fPanColor=[0.2 0.4 1];
gPanColor=[1 0.2 0.1];
EditColor=[0.95 0.95 0.95];
InstructColor=[0.75 0.75 0.75];
numpts=500;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%% Instructions Window %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

InstructFigure=figure(...
    'Units','Pixels',...
    'Position',[0 38 300 850],...
    'MenuBar','None',...
    'NumberTitle','off',...
    'Color',InstructColor,...
    'Name','Instruction for Calculator');

Instructions0='Instructions for Calculator';
Instructions1='Calculator is used to calculate the Symbolic first and second derivatives of two single-variable functions.  Calculator also graphs the primary functions, its first and second derivatives, and the definite integral (area under the curve from the lower to upper bounds) on the given axes.  CalcGUI allows for two simultaneous equations to be acted upon.';
Instructions2='Using the Primary Function panels.';
Instructions3='Enter the primary equation into the Edit Rectangle (nearly-white).  After doing so, you may show the graph of the entered function on the axes by pushing the Radio Button above and to the left of your equation.  ***Note: The equation MUST be a single-variable equation.';
Instructions4='Using the 1st and 2nd Derivatives panels.';
Instructions5='After entering an equation into the Primary Function panel above, you can calculate and show the first and second derivatives of the primary function.  Pushing the Radio button next to f`(x) will display the first derivative of the primary function and graph it.  Pushing the Radio button next to f``(x) will calculate and graph the second derivative of the primary function.  Pressing either Radio button again will recalculate the derivative and remove the graph. ';
Instructions6='Using the Definite Integral panels.';
Instructions7='After entering an equation into the Primary Function panel above, you can calculate and show the definite integral of the primary function.  First, enter both Lower and Upper Bounds to integrate.  When you push the ''Calculate Area'' button, the definite integral of the primary function from the Lower Bound to the Upper Bound will be displayed in the rectangle above the button.  Pressing the Radio button will display the area under the curve between the lower and upper bounds, representing the area attained.';

InstructText0=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 825 290 25],...
    'String',Instructions0,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor,...
    'FontWeight','Bold',...
    'FontSize',14);

InstructText1=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 680 290 135],...
    'String',Instructions1,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor);

InstructText2=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 650 290 20],...
    'String',Instructions2,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor,...
    'FontWeight','Bold');

InstructText3=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 523 290 125],...
    'String',Instructions3,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor);

InstructText4=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 493 290 20],...
    'String',Instructions4,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor,...
    'FontWeight','Bold');

InstructText5=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 303 290 190],...
    'String',Instructions5,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor);

InstructText6=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 274 290 20],...
    'String',Instructions6,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor,...
    'FontWeight','Bold');

InstructText7=uicontrol(...
    'Style','Text',...
    'Parent',InstructFigure,...
    'Units','Pixels',...
    'Position',[5 75 290 200],...
    'String',Instructions7,...
    'HorizontalAlignment','Left',...
    'BackgroundColor',InstructColor);



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Primary Figure Window
hFigure=figure(...
    'Units','Pixels',...
    'Position',[308 38 1200 800],...
    'Color',hFigColor,...
    'MenuBar','None',...
    'NumberTitle','off',...
    'Name','CalcGUI');

%Axes
hAxes=axes(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[300 150 600 600],...
    'XGrid','on',...
    'YGrid','on',...
    'XLim',[-10 10],...
    'YLim',[-10,10]);

%Title
hTitle=uicontrol(...
    'Style','Text',...
    'Units','Pixels',...
    'Parent',hFigure,...
    'Position',[300 750 600 30],...
    'BackgroundColor',hFigColor,...
    'String','Single Variable Calculus Calculator with 2 Functions',...
    'FontSize',16,...
    'HorizontalAlignment','Center');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Image Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This creates the 'background' axes
ImAxes=axes(...
    'Parent',hFigure,...
    'Units','Normalized',...
    'Position',[0 0 1 1]);

% Move the background axes to the bottom
uistack(ImAxes,'bottom');

% Load in a background image and display it using the correct colors
% The image used below, is in the Image Processing Toolbox. If you do not have %access to this toolbox, you can use another image file instead.
I=imread('ConTrail.png');
Im=imagesc(I);
colormap gray

% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ImAxes,...
    'handlevisibility','off', ...
    'visible','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Line Setup
fLine=line();
set(fLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','b');

ffLine=line();
set(ffLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','b');

fffLine=line();
set(fffLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','b');

gLine=line();
set(gLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','r');

ggLine=line();
set(ggLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','r');

gggLine=line();
set(gggLine,...
    'XData',[],...
    'YData',[],...
    'LineStyle','none',...
    'LineWidth',2,...
    'Color','r');

xaxis=line([-1000000,1000000],[0,0],...
    'Color','k',...
    'LineWidth',1.3);

yaxis=line([0,0],[-1000000,1000000],...
    'Color','k',...
    'LineWidth',1.3);

hold on

areaf=area(0);
set(areaf,'YData',0,...
    'EdgeColor','none',...
    'FaceColor','none');

areag=area(0);
set(areag,'YData',0,...
    'EdgeColor','none',...
    'FaceColor','none');

hold off

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%X and Y Limits Panel
xyPanel=uipanel(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[300 20 600 100],...
    'BackgroundColor',xyPanColor);

%xy xMin Text: X Min
xMinText=uicontrol(...
    'Style','Text',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[10 60 60 25],...
    'BackgroundColor',xyPanColor,...
    'String','X Min: ',...
    'HorizontalAlignment','Left',...
    'FontSize',12);

%xy xMin Edit
xMinEdit=uicontrol(...
    'Style','Edit',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[80 60 200 25],...
    'String','-10',...
    'HorizontalAlignment','Left',...
    'FontSize',8,...
    'Callback',@xMin_Callback);

%xy xMax Text: X Max
xMaxText=uicontrol(...
    'Style','Text',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[10 15 60 25],...
    'BackgroundColor',xyPanColor,...
    'String','X Max: ',...
    'HorizontalAlignment','Left',...
    'FontSize',12);

%xy xMax Edit
xMaxEdit=uicontrol(...
    'Style','Edit',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[80 15 200 25],...
    'String','10',...
    'HorizontalAlignment','Left',...
    'FontSize',8,...
    'Callback',@xMax_Callback);

%xy yMin Text: Y Min
yMinText=uicontrol(...
    'Style','Text',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[310 60 60 25],...
    'BackgroundColor',xyPanColor,...
    'String','Y Min: ',...
    'HorizontalAlignment','Left',...
    'FontSize',12);

%xy yMin Edit
yMinEdit=uicontrol(...
    'Style','Edit',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[380 60 200 25],...
    'String','-10',...
    'HorizontalAlignment','Left',...
    'FontSize',8,...
    'Callback',@yMin_Callback);

%xy yMax Text: Y Max
yMaxText=uicontrol(...
    'Style','Text',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[310 15 60 25],...
    'BackgroundColor',xyPanColor,...
    'String','Y Max: ',...
    'HorizontalAlignment','Left',...
    'FontSize',12);

%xy yMax Edit
yMaxEdit=uicontrol(...
    'Style','Edit',...
    'Parent',xyPanel,...
    'Units','Pixels',...
    'Position',[380 15 200 25],...
    'String','10',...
    'HorizontalAlignment','Left',...
    'FontSize',8,...
    'Callback',@yMax_Callback);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%fPanel
fPanel=uipanel(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[30 150 240 600],...
    'BackgroundColor',fPanColor);

%%%%%%%%%%%%%%% f(x) Primary Function %%%%%%%%%%%%%%%

%f(x) Primary Function Panel
fFcnPanel=uipanel(...
    'Parent',fPanel,...
    'Units','Pixels',...
    'Position',[10 490 220 100],...
    'BackgroundColor',fPanColor);

%f(x) Text: Primary Function f(x)
fFcnTitleText=uicontrol(...
    'Style','Text',...
    'Parent',fFcnPanel,...
    'Units','Pixels',...
    'Position',[10 60 200 30],...
    'BackgroundColor',fPanColor,...
    'String','Primary Function f(x)',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%f(x) Text f(x)=
fFcnText=uicontrol(...
    'Style','Text',...
    'Parent',fFcnPanel,...
    'Units','Pixels',...
    'Position',[33 33 30 30],...
    'BackgroundColor',fPanColor,...
    'String','f(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Radio Button
fFcnRadio=uicontrol(...
    'Style','Radio',...
    'Parent',fFcnPanel,...
    'Units','Pixels',...
    'Position',[10 45 20 20],...
    'BackgroundColor',fPanColor,...
    'Callback',@fFcnShg_Callback);

%f(x) Edit f(x)
fFcn=uicontrol(...
    'Style','Edit',...
    'Parent',fFcnPanel,...
    'Units','Pixels',...
    'Position',[10 10 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%%%%%%%%%%%%%%% f(x) Derivatives %%%%%%%%%%%%%%%

%f(x) Derivative Panel
fDerivPanel=uipanel(...
    'Parent',fPanel,...
    'Units','Pixels',...
    'Position',[10 300 220 180],...
    'BackgroundColor',fPanColor);

%f(x) Text: 1st and 2nd Derivatives
fDerivTitleText=uicontrol(...
    'Style','Text',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[10 140 200 30],...
    'BackgroundColor',fPanColor,...
    'String','1st and 2nd Derivatives',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%f`(x) Text f`(x)=
fDerivText=uicontrol(...
    'Style','Text',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[33 118 45 20],...
    'BackgroundColor',fPanColor,...
    'String','f`(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f`(x) Radio Button
fDerivRadio=uicontrol(...
    'Style','Radio',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[10 120 20 20],...
    'BackgroundColor',fPanColor,...
    'Callback',@fDerivShg_Callback);

%f`(x) f`(x) Text
fDeriv=uicontrol(...
    'Style','Text',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[10 85 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8,...
    'Callback',@fDeriv_Callback);

%f``(x) Text f``(x)=
fDeriv2Text=uicontrol(...
    'Style','Text',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[33 53 45 20],...
    'BackgroundColor',fPanColor,...
    'String','f``(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f``(x) Radio Button
fDeriv2Radio=uicontrol(...
    'Style','Radio',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[10 55 20 20],...
    'BackgroundColor',fPanColor,...
    'Callback',@fDeriv2Shg_Callback);

%f``(x) f``(x) Text
fDeriv2=uicontrol(...
    'Style','Text',...
    'Parent',fDerivPanel,...
    'Units','Pixels',...
    'Position',[10 20 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8,...
    'Callback',@fDeriv2_Callback);

%%%%%%%%%%%%%%% f(x) Integrals %%%%%%%%%%%%%%%

%f(x) Integral Panel
fIntPanel=uipanel(...
    'Parent',fPanel,...
    'Units','Pixels',...
    'Position',[10 10 220 280],...
    'BackgroundColor',fPanColor);

%f(x) Text: Definite Integral of f(x)
fIntTitleText=uicontrol(...
    'Style','Text',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 240 200 30],...
    'BackgroundColor',fPanColor,...
    'String','Definite Integral of f(x)',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%f(x) Text: Lower Bound
fIntLowText=uicontrol(...
    'Style','Text',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 190 80 30],...
    'BackgroundColor',fPanColor,...
    'String','Lower Bound:',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Edit Lower Bound
fIntLowEdit=uicontrol(...
    'Style','Edit',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[90 200 120 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Text: Upper Bound
fIntUpText=uicontrol(...
    'Style','Text',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 140 80 30],...
    'BackgroundColor',fPanColor,...
    'String','Upper Bound:',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Edit Upper Bound
fIntUpEdit=uicontrol(...
    'Style','Edit',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[90 150 120 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Text: Area=
fIntAreaText=uicontrol(...
    'Style','Text',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 90 200 40],...
    'BackgroundColor',fPanColor,...
    'String','Area Under f(x) from the Lower to Upper Bound=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%f(x) Area Text
fIntArea=uicontrol(...
    'Style','Text',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 60 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8);

%f(x) Area Radio Button
fShowAreaRadio=uicontrol(...
    'Style','Radio',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[10 20 20 20],...
    'BackgroundColor',fPanColor,...
    'Callback',@fIntRadio_Callback);

%f(x) Area Push Button
fShowAreaPush=uicontrol(...
    'Style','Push',...
    'Parent',fIntPanel,...
    'Units','Pixels',...
    'Position',[30 15 180 30],...
    'BackgroundColor',fPanColor,...
    'String','Calculate Area',...
    'Callback',@fIntShowArea_Callback);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% g(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%gPanel
gPanel=uipanel(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[930 150 240 600],...
    'BackgroundColor',gPanColor);

%%%%%%%%%%%%%%% g(x) Primary Function %%%%%%%%%%%%%%%

%g(x) Primary Function Panel
gFcnPanel=uipanel(...
    'Parent',gPanel,...
    'Units','Pixels',...
    'Position',[10 490 220 100],...
    'BackgroundColor',gPanColor);

%g(x) Text: Primary Function g(x)
gFcnTitleText=uicontrol(...
    'Style','Text',...
    'Parent',gFcnPanel,...
    'Units','Pixels',...
    'Position',[10 60 200 30],...
    'BackgroundColor',gPanColor,...
    'String','Primary Function g(x)',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%g(x) Text g(x)=
gFcnText=uicontrol(...
    'Style','Text',...
    'Parent',gFcnPanel,...
    'Units','Pixels',...
    'Position',[33 33 30 30],...
    'BackgroundColor',gPanColor,...
    'String','g(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Radio Button
gFcnRadio=uicontrol(...
    'Style','Radio',...
    'Parent',gFcnPanel,...
    'Units','Pixels',...
    'Position',[10 45 20 20],...
    'BackgroundColor',gPanColor,...
    'Callback',@gFcnShg_Callback);

%g(x) Edit g(x)
gFcn=uicontrol(...
    'Style','Edit',...
    'Parent',gFcnPanel,...
    'Units','Pixels',...
    'Position',[10 10 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%%%%%%%%%%%%%%% g(x) Derivatives %%%%%%%%%%%%%%%

%g(x) Derivative Panel
gDerivPanel=uipanel(...
    'Parent',gPanel,...
    'Units','Pixels',...
    'Position',[10 300 220 180],...
    'BackgroundColor',gPanColor);

%g(x) Text: 1st and 2nd Derivatives
gDerivTitleText=uicontrol(...
    'Style','Text',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[10 140 200 30],...
    'BackgroundColor',gPanColor,...
    'String','1st and 2nd Derivatives',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%g`(x) Text g`(x)=
gDerivText=uicontrol(...
    'Style','Text',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[33 118 45 20],...
    'BackgroundColor',gPanColor,...
    'String','g`(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g`(x) Radio Button
gDerivRadio=uicontrol(...
    'Style','Radio',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[10 120 20 20],...
    'BackgroundColor',gPanColor,...
    'Callback',@gDerivShg_Callback);

%g`(x) g`(x) Text
gDeriv=uicontrol(...
    'Style','Text',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[10 85 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8);

%g``(x) Text g``(x)=
gDeriv2Text=uicontrol(...
    'Style','Text',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[33 53 45 20],...
    'BackgroundColor',gPanColor,...
    'String','g``(x)=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g``(x) Radio Button
gDeriv2Radio=uicontrol(...
    'Style','Radio',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[10 55 20 20],...
    'BackgroundColor',gPanColor,...
    'Callback',@gDeriv2Shg_Callback);

%g``(x) g``(x) Text
gDeriv2=uicontrol(...
    'Style','Text',...
    'Parent',gDerivPanel,...
    'Units','Pixels',...
    'Position',[10 20 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8);

%%%%%%%%%%%%%%% g(x) Integrals %%%%%%%%%%%%%%%

%g(x) Integral Panel
gIntPanel=uipanel(...
    'Parent',gPanel,...
    'Units','Pixels',...
    'Position',[10 10 220 280],...
    'BackgroundColor',gPanColor);

%g(x) Text: Definite Integral of g(x)
gIntTitleText=uicontrol(...
    'Style','Text',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 240 200 30],...
    'BackgroundColor',gPanColor,...
    'String','Definite Integral of g(x)',...
    'HorizontalAlignment','Center',...
    'FontSize',12);

%g(x) Text: Lower Bound
gIntLowText=uicontrol(...
    'Style','Text',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 190 80 30],...
    'BackgroundColor',gPanColor,...
    'String','Lower Bound:',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Edit Lower Bound
gIntLowEdit=uicontrol(...
    'Style','Edit',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[90 200 120 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Text: Upper Bound
gIntUpText=uicontrol(...
    'Style','Text',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 140 80 30],...
    'BackgroundColor',gPanColor,...
    'String','Upper Bound:',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Edit Upper Bound
gIntUpEdit=uicontrol(...
    'Style','Edit',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[90 150 120 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Text: Area=
gIntAreaText=uicontrol(...
    'Style','Text',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 90 200 40],...
    'BackgroundColor',gPanColor,...
    'String','Area Under g(x) from the Lower to Upper Bound=',...
    'HorizontalAlignment','Left',...
    'FontSize',8);

%g(x) Area Text
gIntArea=uicontrol(...
    'Style','Text',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 60 200 25],...
    'BackgroundColor',EditColor,...
    'String','',...
    'HorizontalAlignment','Center',...
    'FontSize',8);

%g(x) Area Radio Button
gShowAreaRadio=uicontrol(...
    'Style','Radio',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[10 20 20 20],...
    'BackgroundColor',gPanColor,...
    'Callback',@gIntRadio_Callback);

%g(x) Area Push Button
gShowAreaPush=uicontrol(...
    'Style','Push',...
    'Parent',gIntPanel,...
    'Units','Pixels',...
    'Position',[30 15 180 30],...
    'BackgroundColor',gPanColor,...
    'String','Calculate Area',...
    'Callback',@gIntShowArea_Callback);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% Normalize All Handles %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

handles=[InstructFigure,InstructText0,InstructText1,InstructText2,...
    InstructText3,InstructText4,InstructText5,InstructText6,...
    InstructText7,InstructText8,hFigure,hAxes,hTitle,xyPanel,...
    xMinText,xMinEdit,xMaxText,xMaxEdit,yMinText,yMinEdit,yMaxText,...
    yMaxEdit,fPanel,fFcnPanel,fFcnTitleText,fFcnText,fFcnRadio,fFcn,...
    fDerivPanel,fDerivTitleText,fDerivText,fDerivRadio,fDeriv,...
    fDeriv2Text,fDeriv2Radio,fDeriv2,fIntPanel,fIntTitleText,...
    fIntLowText,fIntLowEdit,fIntUpText,fIntUpEdit,fIntAreaText,fIntArea,...
    fShowAreaRadio,fShowAreaPush,gPanel,gFcnPanel,gFcnTitleText,...
    gFcnText,gFcnRadio,gFcn,gDerivPanel,gDerivTitleText,gDerivText,...
    gDerivRadio,gDeriv,gDeriv2Text,gDeriv2Radio,gDeriv2,gIntPanel,...
    gIntTitleText,gIntLowText,gIntLowEdit,gIntUpText,gIntUpEdit,...
    gIntAreaText,gIntArea,gShowAreaRadio,gShowAreaPush];
set(handles,...
    'Units','Normalized');



%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Callbacks %%%%%%%%%%%%%%%%%%%%%%%%%%%%

% xy xMin Callback
    function xMin_Callback(hObject,eventdata)
        x=get(hAxes,'XLim');
        xmin=str2double(get(hObject,'String'));
        set(hAxes,'XLim',[xmin x(2)])
    end %ends xMin_Callback

% xy xMax Callback
    function xMax_Callback(hObject,eventdata)
        x=get(hAxes,'XLim');
        xmax=str2double(get(hObject,'String'));
        set(hAxes,'XLim',[x(1) xmax])
    end %ends xMax_Callback

% xy yMin Callback
    function yMin_Callback(hObject,eventdata)
        y=get(hAxes,'YLim');
        ymin=str2double(get(hObject,'String'));
        set(hAxes,'YLim',[ymin y(2)])
    end %ends yMin_Callback

% xy yMax Callback
    function yMax_Callback(hObject,eventdata)
        y=get(hAxes,'YLim');
        ymax=str2double(get(hObject,'String'));
        set(hAxes,'YLim',[y(1) ymax])
    end %ends yMax_Callback


% % f(x) Primary Function Callback
%     function fFcn_Callback(hObject,eventdata)
%     end %ends fFcn_Callback
%
% f(x) Primary Function Show Graph Callback
    function fFcnShg_Callback(hObject,eventdata)
        f=fcnchk(get(fFcn,'String'),'vectorized');
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        y=feval(f,xx);

        fswitch=get(hObject,'Value');
        switch fswitch
            case 0
                set(fLine,...
                    'LineStyle','none');
            case 1
                set(fLine,...
                    'XData',xx,...
                    'YData',y,...
                    'LineStyle','-');
        end
    end %ends fFcnShg_Callback

% f`(x) Function Show Graph Callback
    function fDerivShg_Callback(hObject,eventdata)
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        f=get(fFcn,'String');
        ff=char(diff(f));

        set(fDeriv,'String',ff);

        y=fcnchk(get(fDeriv,'String'),'vectorized');
        yy=feval(y,xx);

        ffswitch=get(hObject,'Value');
        switch ffswitch
            case 0
                set(ffLine,...
                    'LineStyle','none');
            case 1
                set(ffLine,...
                    'XData',xx,...
                    'YData',yy,...
                    'LineStyle','--');
        end
    end %ends fDerivShg_Callback

% f``(x) Function Show Graph Callback
    function fDeriv2Shg_Callback(hObject,eventdata)
        fffswitch=get(hObject,'Value');
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        ff=get(fDeriv,'String');
        fff=char(diff(ff));

        set(fDeriv2,'String',fff);

        y=fcnchk(get(fDeriv2,'String'),'vectorized');
        yy=feval(y,xx);

        switch fffswitch
            case 0
                set(fffLine,'LineStyle','none');
            case 1
                set(fffLine,...
                    'XData',xx,...
                    'YData',yy,...
                    'LineStyle',':');
        end
    end %ends fDeriv2Shg_Callback

% f(x) Integral Show Area on Graph Callback
    function fIntRadio_Callback(hObject,eventdata)
        a=str2double(get(fIntLowEdit,'String'));
        b=str2double(get(fIntUpEdit,'String'));
        fareafswitch=get(hObject,'Value');
        switch fareafswitch
            case 0
                set(areaf,...
                    'XData',[],...
                    'YData',0,...
                    'FaceColor','none');
            case 1
                x=get(fLine,'XData');
                y=get(fLine,'YData');
                k=((a<=x) & (x<=b));
                yy=y(k);
                numberpoints=size(yy);
                xx=linspace(a,b,numberpoints(2));
                set(areaf,...
                    'XData',xx,...
                    'YData',yy,...
                    'FaceColor',fPanColor);

                xmin=str2double(get(xMinEdit,'String'));
                xmax=str2double(get(xMaxEdit,'String'));
                ymin=str2double(get(yMinEdit,'String'));
                ymax=str2double(get(yMaxEdit,'String'));
                set(hAxes,...
                    'XLim',[xmin xmax],...
                    'YLim',[ymin ymax]);
        end
    end %ends fIntRadio_Callback

% f(x) Integral Calculate Area Callback
    function fIntShowArea_Callback(hObject,eventdata)
        f=get(fFcn,'String');
        a=str2double(get(fIntLowEdit,'String'));
        b=str2double(get(fIntUpEdit,'String'));
        farea=double(int(f,a,b));
        set(fIntArea,'String',farea);
    end %ends fIntShowArea_Callback

% g(x) Primary Function Callback
    function gFcn_Callback(hObject,eventdata)

    end %ends gFcn_Callback

% g(x) Primary Function Show Graph Callback
    function gFcnShg_Callback(hObject,eventdata)
        g=fcnchk(get(gFcn,'String'),'vectorized');
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        y=feval(g,xx);

        gswitch=get(hObject,'Value');
        switch gswitch
            case 0
                set(gLine,'LineStyle','none');
            case 1
                set(gLine,...
                    'XData',xx,...
                    'YData',y,...
                    'LineStyle','-');
        end
    end %ends gFcnShg_Callback

% g`(x) Function Show Graph Callback
    function gDerivShg_Callback(hObject,eventdata)
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        g=get(gFcn,'String');
        gg=char(diff(g));

        set(gDeriv,'String',gg);

        y=fcnchk(get(gDeriv,'String'),'vectorized');
        yy=feval(y,xx);

        ggswitch=get(hObject,'Value');
        switch ggswitch
            case 0
                set(ggLine,...
                    'LineStyle','none');
            case 1
                set(ggLine,...
                    'XData',xx,...
                    'YData',yy,...
                    'LineStyle','--');
        end
    end %ends gDerivShg_Callback

% g``(x) Function Show Graph Callback
    function gDeriv2Shg_Callback(hObject,eventdata)
        gggswitch=get(hObject,'Value');
        x=get(hAxes,'XLim');
        xx=linspace(x(1),x(2),numpts);
        gg=get(gDeriv,'String');
        ggg=char(diff(gg));

        set(gDeriv2,'String',ggg);

        y=fcnchk(get(gDeriv2,'String'),'vectorized');
        yy=feval(y,xx);

        switch gggswitch
            case 0
                set(gggLine,...
                    'LineStyle','none');
            case 1
                set(gggLine,...
                    'XData',xx,...
                    'YData',yy,...
                    'LineStyle',':');
        end
    end %ends gDeriv2Shg_Callback

    function gIntRadio_Callback(hObject,eventdata)
        a=str2double(get(gIntLowEdit,'String'));
        b=str2double(get(gIntUpEdit,'String'));
        gareagswitch=get(hObject,'Value');
        switch gareagswitch
            case 0
                set(areag,...
                    'XData',[],...
                    'YData',0,...
                    'FaceColor','none');
            case 1
                x=get(gLine,'XData');
                y=get(gLine,'YData');
                k=((a<=x) & (x<=b));
                yy=y(k);
                numberpoints=size(yy);
                xx=linspace(a,b,numberpoints(2));
                set(areag,...
                    'XData',xx,...
                    'YData',yy,...
                    'FaceColor',gPanColor);

                xmin=str2double(get(xMinEdit,'String'));
                xmax=str2double(get(xMaxEdit,'String'));
                ymin=str2double(get(yMinEdit,'String'));
                ymax=str2double(get(yMaxEdit,'String'));
                set(hAxes,...
                    'XLim',[xmin xmax],...
                    'YLim',[ymin ymax]);
        end
    end %ends gIntRadio_Callback

% g(x) Integral Show Area on Graph Callback
    function gIntShowArea_Callback(hObject,eventdata)
        g=get(gFcn,'String');
        a=str2double(get(gIntLowEdit,'String'));
        b=str2double(get(gIntUpEdit,'String'));
        garea=double(int(g,a,b));
        set(gIntArea,'String',garea);
    end %ends gIntShowArea_Callback

end

Sunday, 22 June 2014

Automatic Water level Controller using 555 timer


Water is an essential element in our daily life. Every day we need a huge amount of water in various purposes, but to fulfill this demand we waste a lot of water as well as electricity. Specially, the people who are using motor (water) pump to pull up water in the water tank, they frequently forget to switch-off motor pump. Here we developed an electrical circuit that helps people to automatically switched-off motor (water) pump, when the water tank is full and it helps to automatically switched-on when the water tank is empty.its a very simple project,where we use 555 timer IC.using this circuit unwanted water flow can be prevented from water tank.
the required components are:
1.555 IC x 1
2.realy x 1
3.leaf switch x 2
4.resistor 4.7k
5.transistor SL100
6.capacitor 0.01uf 

MATLAB code for electronic piano

function keys

clear all
close all
clc
% MISC PARAMETERS
fontsize=[10];
timekeycolor=[0.7,0.0,0.0];
soundkeycolor=[0.0,0.0,0.7];
keycolor1=[1.0,1.0,1.0];
keycolor2=[1.0,1.0,1.0];
keycolor3=[0.0,0.0,0.0];
keycolor4=[0.0,0.0,0.0];

% FIGURE
hFigure=figure(...
    'Units','Pixels',...
    'Position',[90 400 831 350],...
    'Color','k',...
    'MenuBar','none',...
    'Toolbar','none',...
    'NumberTitle','off',...
    'Name','KEYS');

% TIME BUTTONS
hbuttonGroup=uibuttongroup(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[0 301 831 25],...
    'BackgroundColor',[0,0,0],...
    'SelectionChangeFcn',@timeSelection_callback);

time1=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup,...
    'Units','Pixels',...
    'Position',[ 3 3 164 15],...
    'String','T I M E 1',...
    'FontSize',8,...
    'ForegroundColor',timekeycolor,...
    'BackgroundColor',timekeycolor);

time2=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup,...
    'Units','Pixels',...
    'Position',[168 3 164 15],...
    'String','T I M E 2',...
    'FontSize',8,...
    'ForegroundColor',timekeycolor,...
    'BackgroundColor',timekeycolor);

time3=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup,...
    'Units','Pixels',...
    'Position',[333 3 164 15],...
    'String','T I M E 3',...
    'FontSize',8,...
    'ForegroundColor',timekeycolor,...
    'BackgroundColor',timekeycolor);

time4=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup,...
    'Units','Pixels',...
    'Position',[498 3 164 15],...
    'String','T I M E 4',...
    'FontSize',8,...
    'ForegroundColor',timekeycolor,...
    'BackgroundColor',timekeycolor);

tuner=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup,...
    'Units','Pixels',...
    'Position',[663 3 164 15],...
    'String','T U N E R  T I M E',...
    'FontSize',8,...
    'ForegroundColor',timekeycolor,...
    'BackgroundColor',timekeycolor);

% SOUND BUTTONS

hbuttonGroup2=uibuttongroup(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[0 326 831 25],...
    'BackgroundColor',[0,0,0],...
    'SelectionChangeFcn',@fsoundSelection_callback);

snd1=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup2,...
    'Units','Pixels',...
    'Position',[3 3 164 15],...
    'String','S O U N D  1',...
    'FontSize',8,...
    'ForegroundColor',soundkeycolor,...
    'BackgroundColor',soundkeycolor);

snd2=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup2,...
    'Units','Pixels',...
    'Position',[168 3 164 15],...
    'String','S O U N D  2',...
    'FontSize',8,...
    'ForegroundColor',soundkeycolor,...
    'BackgroundColor',soundkeycolor);

snd3=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup2,...
    'Units','Pixels',...
    'Position',[333 3 164 15],...
    'String','S O U N D  3',...
    'FontSize',8,...
    'ForegroundColor',soundkeycolor,...
    'BackgroundColor',soundkeycolor);

snd4=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup2,...
    'Units','Pixels',...
    'Position',[498 3 164 15],...
    'String','S O U N D  4',...
    'FontSize',8,...
    'ForegroundColor',soundkeycolor,...
    'BackgroundColor',soundkeycolor);

snd5=uicontrol(...
    'Style','togglebutton',...
    'Parent',hbuttonGroup2,...
    'Units','Pixels',...
    'Position',[663 3 164 15],...
    'String','S O U N D  5',...
    'FontSize',8,...
    'ForegroundColor',soundkeycolor,...
    'BackgroundColor',soundkeycolor)

% KEYS
hButtonGroup=uibuttongroup(...
    'Parent',hFigure,...
    'Units','Pixels',...
    'Position',[0 0 831 300],...
    'BackgroundColor',[0,0,0],...
    'SelectionChangeFcn',@noteSelection_callback);

% WHITE KEYS (t1 - t15)
t1=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[ 0 0 60 300],...
    'String','C3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t2=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[55 0 60 300],...
    'String','D3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t3=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[110 0 60 300],...
    'String','E3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t4=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[165 0 60 300],...
    'String','F3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t5=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[220 0 60 300],...
    'String','G3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t6=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[275 0 60 300],...
    'String','A3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t7=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[330 0 60 300],...
    'String','B3',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t8=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[385 0 60 300],...
    'String','C4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t9=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[440 0 60 300],...
    'String','D4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t10=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[495 0 60 300],...
    'String','E4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t11=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[550 0 60 300],...
    'String','F4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t12=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[605 0 60 300],...
    'String','G4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t13=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[660 0 60 300],...
    'String','A4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t14=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[715 0 60 300],...
    'String','B4',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

t15=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[770 0 60 300],...
    'String','C5',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor1,...
    'BackgroundColor',keycolor2);

% BLACK KEYS (t16-t25)
t16=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[30 140 40 160],...
    'String','C3s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t17=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[100 140 40 160],...
    'String','D3s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t18=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[195 140 40 160],...
    'String','F3s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);
t19=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[258 140 40 160],...
    'String','G3s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t20=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[320 140 40 160],...
    'String','A3s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t21=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[423 140 40 160],...
    'String','C4s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t22=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[485 140 40 160],...
    'String','D4s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t23=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[580 140 40 160],...
    'String','F4s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t24=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[642 140 40 160],...
    'String','G4s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

t25=uicontrol(...
    'Style','togglebutton',...
    'Parent',hButtonGroup,...
    'Units','Pixels',...
    'Position',[705 140 40 160],...
    'String','A4s',...
    'FontSize',fontsize,...
    'ForegroundColor',keycolor3,...
    'BackgroundColor',keycolor4);

% FUNCTIONS
t=0.6;
    function timeSelection_callback(hObject,eventdata)
        T=get(eventdata.NewValue,'String');

        switch T
            case 'T I M E 1'
                t=0.2;
            case 'T I M E 2'
                t=0.4;
            case 'T I M E 3'
                t=0.6;
            case 'T I M E 4'
                t=1.0;
            case 'T U N E R  T I M E'
                t=10.0;
        end
    end % END OF TIME FUNCTION

f=0.0;
    function fsoundSelection_callback(hObject,eventdata)
        F=get(eventdata.NewValue,'String');

        switch F
            case 'S O U N D  1'
                f=0.0;
            case 'S O U N D  2'
                f=0.2;
            case 'S O U N D  3'
                f=0.3;
            case 'S O U N D  4'
                f=0.4;
            case 'S O U N D  5'
                f=0.8;
        end
    end % END OF FSOUND FUNCTION

    function noteSelection_callback(hObject,eventdata)
        N=get(eventdata.NewValue,'String');
        x=linspace(0,t*30*pi,t*5000);

        switch N
            case 'C3'
                y=sin(0.5*10.65*x)+f*sin(0.5*(10.65+f)*x);
                sound(y)
            case 'D3'
                y=sin(0.5*11.95*x)+f*sin(0.5*(11.95+f)*x);
                sound(y)
            case 'E3'
                y=sin(0.5*13.4*x)+f*sin(0.5*(13.4+f)*x);
                sound(y)
            case 'F3'
                y=sin(0.5*14.2*x)+f*sin(0.5*(14.2+f)*x);
                sound(y)
            case 'G3'
                y=sin(0.5*15.95*x)+f*sin(0.5*(15.95+f)*x);
                sound(y)
            case 'A3'
                y=sin(8.95*x)+f*sin((8.95+f)*x);
                sound(y)
            case 'B3'
                y=sin(10.05*x)+f*sin((10.05+f)*x);
                sound(y)
            case 'C4'
                y=sin(10.65*x)+f*sin((10.65+f)*x);
                sound(y)
            case 'D4'
                y=sin(11.95*x)+f*sin((11.95+f)*x);
                sound(y)
            case 'E4'
                y=sin(13.4*x)+f*sin((13.4+f)*x);
                sound(y)
            case 'F4'
                y=sin(14.2*x)+f*sin((14.2+f)*x);
                sound(y)
            case 'G4'
                y=sin(15.95*x)+f*sin((15.95+f)*x);
                sound(y)
            case 'A4'
                y=sin(2*8.95*x)+f*sin(2*(8.95+f)*x);
                sound(y)
            case 'B4'
                y=sin(2*10.05*x)+f*sin(2*(10.65+f)*x);
                sound(y)
            case 'C5'
                y=sin(2*10.65*x)+f*sin(2*(10.65+f)*x);
                sound(y)
            case 'C3s'
                y=sin(0.5*11.27*x)+f*sin(0.5*(11.27+f)*x);
                sound(y)
            case 'D3s'
                y=sin(0.5*12.65*x)+f*sin(0.5*(12.65+f)*x);
                sound(y)
            case 'F3s'
                y=sin(0.5*15.05*x)+f*sin(0.5*(15.05+f)*x);
                sound(y)
            case 'G3s'
                y=sin(0.5*16.88*x)+f*sin(0.5*(16.88+f)*x);
                sound(y)
            case 'A3s'
                y=sin(9.48*x)+f*sin(0.5*(9.48+f)*x);
                sound(y)
            case 'C4s'
                y=sin(11.275*x)+f*sin(0.5*(11.275+f)*x);
                sound(y)
            case 'D4s'
                y=sin(12.66*x)+f*sin(0.5*(12.66+f)*x);
                sound(y)
            case 'F4s'
                y=sin(15.05*x)+f*sin(0.5*(15.05+f)*x);
                sound(y)
            case 'G4s'
                y=sin(16.88*x)+f*sin(0.5*(16.88+f)*x);
                sound(y)
            case 'A4s'
                y=sin(2*9.48*x)+f*sin(2*(9.48+f)*x);
                sound(y)
        end
    end
end % END OF NOTE FUNCTION