Final Project

Be Careful to Fall

Idea

When we walk by a single-plank bridge, we must be care of falling. So, this progrem help us to check if we just maintain balance.

First, it will show "start icon", then start to detect x/y/z.

Second, it might have three possibilty icon: 1. stable 2. left 3. right

Third, you should correct it turn back to be stable:

If you don't do it, the icon will show "Warning" then turn back to detect.

If you do it, it will show "Great" then continue to detect.

Video

Code and Comment

clear all
global go;
ready=0;
m = mobiledev;                                      *m read monile phone signal
pic=imread('start.jpg');                     *read start picture
image(pic);
while ready==0
    pause(1);
    m.Logging = 1;                                   *start
    pause(2);                                              *read 2 sec
m.Logging = 0;                                *stop
    [or,tor] = orientlog(m);                       
    y = or(:,3);                                                                            
    d = y(end);
    if d>=-25 && d<=25                        *detect range
        pic=imread('stay.jpg');            *nicht zu links oder zu rechts
        image(pic);
        ready=0;
    elseif d>25                                        *detect range
        pic=imread('right.jpg');         *zu rechts
        image(pic);
        ready=1;
        go=0;
    elseif d<-25                                      *detect range
        pic=imread('left.jpg');            *zu links
        image(pic);
        ready=1;
        go=0;
    end
while go==0                                           *read previous "while"'s "go" to judge
    pause(2)
    m.Logging = 1;               
          pause(2);
    m.Logging = 0;  
    [or,tor] = orientlog(m);                                                                        
    x = or(:,3);                                                                            
    e = x(end);                                
    sim('chart');
    w = simout;                                         *read previos picture signal code
      if w==1              
            pic=imread('danger.jpg');    *when read left or right and don't return it stable
            image(pic);                                  *show safe  picture
            ready=0;
            go=1;
      elseif  w==0
            pic=imread('great.jpg');       *maintain stable or let left/right turn back stable
            image(pic);                                 *show fall down picture
            ready=0;
            go=1;
      end
      pause(2);   
end  
end    

Chart

Pictures

Resource

S_S_final_project.rar