-

Dependencies:   mbed

Committer:
lolopo008
Date:
Tue Nov 17 03:08:56 2015 +0000
Revision:
0:e6c5f77b1cae
-

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lolopo008 0:e6c5f77b1cae 1 #include "mbed.h"
lolopo008 0:e6c5f77b1cae 2
lolopo008 0:e6c5f77b1cae 3 Serial bluetooth(D8,D2);
lolopo008 0:e6c5f77b1cae 4
lolopo008 0:e6c5f77b1cae 5 AnalogIn VR(A0);
lolopo008 0:e6c5f77b1cae 6 BusOut main_unit(D3,D4,D5,D6);
lolopo008 0:e6c5f77b1cae 7 BusOut tens(D7,D9,D10,D11);
lolopo008 0:e6c5f77b1cae 8
lolopo008 0:e6c5f77b1cae 9
lolopo008 0:e6c5f77b1cae 10 int main()
lolopo008 0:e6c5f77b1cae 11 {
lolopo008 0:e6c5f77b1cae 12 int num_in,num_mem;
lolopo008 0:e6c5f77b1cae 13 uint8_t menu;
lolopo008 0:e6c5f77b1cae 14 while(1) {
lolopo008 0:e6c5f77b1cae 15 bluetooth.printf("Main Menu\npush 1 to Play with number.\npush 2 to Read voltage from VR\n\n");
lolopo008 0:e6c5f77b1cae 16 menu = bluetooth.getc();
lolopo008 0:e6c5f77b1cae 17 switch(menu) {
lolopo008 0:e6c5f77b1cae 18 case '1':
lolopo008 0:e6c5f77b1cae 19 num_in=0;
lolopo008 0:e6c5f77b1cae 20 num_mem=0;
lolopo008 0:e6c5f77b1cae 21 bluetooth.printf("Please insert number from 0 to 99\n");
lolopo008 0:e6c5f77b1cae 22 bluetooth.scanf("%d/0" ,&num_in);
lolopo008 0:e6c5f77b1cae 23 num_mem=num_in%10;
lolopo008 0:e6c5f77b1cae 24 main_unit=num_mem;
lolopo008 0:e6c5f77b1cae 25 tens=(num_in-num_mem)/10;
lolopo008 0:e6c5f77b1cae 26 bluetooth.printf("Your number is %d\n\n",num_in);
lolopo008 0:e6c5f77b1cae 27 break;
lolopo008 0:e6c5f77b1cae 28 case '2':
lolopo008 0:e6c5f77b1cae 29 bluetooth.printf("Your voltage is %f\n\n", VR.read()*5);
lolopo008 0:e6c5f77b1cae 30 break;
lolopo008 0:e6c5f77b1cae 31 }
lolopo008 0:e6c5f77b1cae 32 }
lolopo008 0:e6c5f77b1cae 33 }