First

Dependencies:   UniGraphic mbed

Committer:
asloop18
Date:
Thu Jan 14 22:52:20 2016 +0000
Revision:
6:459d1eb2cc23
Parent:
4:aa5c976a8761
working game; mission accomplished

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pstephens18 0:f17efa877b15 1 #include "mbed.h"
pstephens18 1:65ea8c2a0551 2 #include "LCD1.h"
asloop18 6:459d1eb2cc23 3 #include "acc.h"
pstephens18 0:f17efa877b15 4
asloop18 6:459d1eb2cc23 5 float x,y;
asloop18 6:459d1eb2cc23 6 float dx,dy; //degrees x,y
asloop18 3:824764571657 7
asloop18 6:459d1eb2cc23 8 int main()
asloop18 6:459d1eb2cc23 9 {
asloop18 6:459d1eb2cc23 10 acc_init();
asloop18 3:824764571657 11 LCD_init();
asloop18 6:459d1eb2cc23 12 x =160;
asloop18 6:459d1eb2cc23 13 y =120;
asloop18 6:459d1eb2cc23 14 dx =0;
asloop18 6:459d1eb2cc23 15 dy=0;
asloop18 6:459d1eb2cc23 16 while(1)
asloop18 6:459d1eb2cc23 17 {
asloop18 6:459d1eb2cc23 18 dx = acc_sense(1);
asloop18 6:459d1eb2cc23 19 dy = acc_sense(2);
asloop18 6:459d1eb2cc23 20 LCD1(x,y); //send pos to LCD to display
asloop18 6:459d1eb2cc23 21 x=x+dy/5; //apply x of sensor to y of screen (alignment)
asloop18 6:459d1eb2cc23 22 y=y+dx/5; //vice-versa
asloop18 3:824764571657 23
asloop18 6:459d1eb2cc23 24 if(x>314)x=314; //prevent loss of bubble
asloop18 6:459d1eb2cc23 25 if(x<6)x=6;
asloop18 6:459d1eb2cc23 26 if(y>234)y=234;
asloop18 6:459d1eb2cc23 27 if(y<6)y=6;
asloop18 6:459d1eb2cc23 28
asloop18 6:459d1eb2cc23 29 LCD2(x,y); //send pos to LCD to display
pstephens18 0:f17efa877b15 30 }
pstephens18 0:f17efa877b15 31 }