First

Dependencies:   UniGraphic mbed

main.cpp

Committer:
asloop18
Date:
2016-01-14
Revision:
6:459d1eb2cc23
Parent:
4:aa5c976a8761

File content as of revision 6:459d1eb2cc23:

#include "mbed.h"
#include "LCD1.h"
#include "acc.h"

float x,y;
float dx,dy;        //degrees x,y

int main() 
{
    acc_init();
    LCD_init();
    x =160;
    y =120;
    dx =0;
    dy=0;
    while(1)
    {
        dx = acc_sense(1);
        dy = acc_sense(2);
        LCD1(x,y);              //send pos to LCD to display
        x=x+dy/5;                 //apply x of sensor to y of screen (alignment)
        y=y+dx/5;                 //vice-versa
        
        if(x>314)x=314;         //prevent loss of bubble
        if(x<6)x=6;
        if(y>234)y=234;
        if(y<6)y=6;
        
        LCD2(x,y);              //send pos to LCD to display
    }
}