Final Project

Motivation


Hello,dear teacher and classmates.

This time , we use matlab with simulink to do a project in final project.

With a lots efforts and energy , I finally finish it already.

I create a game using the data from acceleration sensor.

Let's see how funny the game is!

code

clear all;



pic=imread('1.png');

image(pic);


clear m; %每次開始前清除m中資料

m = mobiledev;


m.Logging = 1;

pause(2); %有2秒時間取值

m.Logging = 0;




[ac, tac] = accellog(m); % accellog

x = ac(:,1); %只取X向量值


k=max(x); %取的所有x中抓出MAX值


disp(max(x));

if max(x)>5 %每下一個if皆包含在前面的if中

pic=imread('1.png');

image(pic);

pause(1);

if max(x)>10

pic=imread('2.png');

image(pic);

pause(1);

if max(x)>20

pic=imread('3.png');

image(pic);

pause(1);

if max(x)>25

pic=imread('4.png');

image(pic);

pause(1);

if max(x)>35

pic=imread('5.png');

image(pic);

pause(1);

if max(x)>40

pic=imread('6.png');

image(pic);

pause(1);

if max(x)>45

pic=imread('7.png');

image(pic);

pause(1);

if max(x)>50

pic=imread('8.png');

image(pic);

pause(1);

if max(x)>55

pic=imread('9.png');

image(pic);

pause(1);

if max(x)>60

pic=imread('10.png');

image(pic);

pause(1);

end

end

end

end

end

end

end

end

end

end




load_system('final'); %進入simulink再傳回

sim('final');


b=max(a);

if b==1

pic=imread('肌肉肌.jpg');

image(pic);

pause(2);

elseif b==2

pic=imread('almost there.jpg');

image(pic);

pause(2);

elseif b==3

pic=imread('keep going.jpg');

image(pic);

pause(2);

elseif b==4

pic=imread('下載.png');

image(pic);

pause(2);

elseif b==5

pic=imread('loser.jpg');

image(pic);

pause(2);

end

Simulink


Five ranks

The worst

The second

The third

Forth

The best !

Demo