a

Dependencies:   BraccialeSlave FTHR_OLED

Committer:
gandhi4
Date:
Mon Feb 25 21:15:43 2019 +0000
Revision:
11:9e3dca611315
Parent:
10:1f5e78dd4a7c
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gandhi4 11:9e3dca611315 1 #include "mbed.h"
gandhi4 11:9e3dca611315 2 #include "Adafruit_SSD1306.h"
gandhi4 11:9e3dca611315 3 Serial bluetooth(D1, D0); // RX TX
gandhi4 11:9e3dca611315 4 I2C i2c(D4, D5); // SDA, SCL
gandhi4 11:9e3dca611315 5 DigitalOut vibMotor(D10);
gandhi4 11:9e3dca611315 6 Serial pc(USBTX, USBRX);
switches 9:ecdad18f61c2 7
switches 0:60a522ae2e35 8 int main()
switches 0:60a522ae2e35 9 {
gandhi4 11:9e3dca611315 10 Adafruit_SSD1306_I2c LCD(i2c);
gandhi4 11:9e3dca611315 11 LCD.display();
gandhi4 11:9e3dca611315 12 char bt_received;
gandhi4 11:9e3dca611315 13 pc.baud(115200);
gandhi4 11:9e3dca611315 14 bluetooth.baud(38400);
switches 1:6923b075c8d7 15
switches 1:6923b075c8d7 16 while(1) {
gandhi4 11:9e3dca611315 17 while (bluetooth.readable()){
gandhi4 11:9e3dca611315 18 LCD.begin();
gandhi4 11:9e3dca611315 19 LCD.display();
gandhi4 11:9e3dca611315 20 bt_received = bluetooth.getc();
gandhi4 11:9e3dca611315 21 pc.printf("Dato Ricevuto: %c\r\n",bt_received);
gandhi4 11:9e3dca611315 22 if (bt_received=='D'){
gandhi4 11:9e3dca611315 23 pc.printf("If \r\n");
gandhi4 11:9e3dca611315 24 LCD.setTextCursor(0,0);
gandhi4 11:9e3dca611315 25 LCD.printf("Bussano alla porta \n");
gandhi4 11:9e3dca611315 26 vibMotor = 1;
gandhi4 11:9e3dca611315 27 LCD.display();
gandhi4 11:9e3dca611315 28 }
gandhi4 11:9e3dca611315 29 else if (bt_received=='P'){
gandhi4 11:9e3dca611315 30 pc.printf("else if \r\n");
gandhi4 11:9e3dca611315 31 LCD.setTextCursor(0,0);
gandhi4 11:9e3dca611315 32 LCD.printf("Bussano al portoncino\n");
gandhi4 11:9e3dca611315 33 vibMotor = 1;
gandhi4 11:9e3dca611315 34 LCD.display();
gandhi4 11:9e3dca611315 35 }
gandhi4 11:9e3dca611315 36 else {
gandhi4 11:9e3dca611315 37 pc.printf("Cancella tutto \r\n");
gandhi4 11:9e3dca611315 38 LCD.setTextCursor(0,0);
gandhi4 11:9e3dca611315 39 LCD.printf(" \n");
gandhi4 11:9e3dca611315 40 vibMotor = 0;
gandhi4 11:9e3dca611315 41 LCD.display();
gandhi4 11:9e3dca611315 42 }
gandhi4 11:9e3dca611315 43 wait_ms(800);
gandhi4 11:9e3dca611315 44
gandhi4 11:9e3dca611315 45 }
gandhi4 11:9e3dca611315 46
switches 8:1d48f139567d 47
switches 0:60a522ae2e35 48 }
switches 0:60a522ae2e35 49 }
switches 0:60a522ae2e35 50