codigo para los grupos MA MB MC de la UPPuebla 2017

Dependencies:   mbed

Fork of Bluetooth_HC-06 by Ohad BarSimanTov

Committer:
icmembed
Date:
Wed Mar 15 19:34:12 2017 +0000
Revision:
1:7768afcb5df1
Parent:
0:feba469f2cf1
codigo para la clase de programacion

Who changed what in which revision?

UserRevisionLine numberNew contents of line
beohad 0:feba469f2cf1 1 // Bluetooth HC-06 may work for HC-05 (I didn't try - check https://mbed.org/users/edodm85/notebook/HC-05-bluetooth/)
beohad 0:feba469f2cf1 2 // Use pins (RXD - PTC4, TXD - PTC3) on FRDM-KL25Z
beohad 0:feba469f2cf1 3 // Use both USBs to power the HC-06 (J9_12 - GND, J9_10 - 5V usb(VCC))
beohad 0:feba469f2cf1 4 #include "mbed.h"
icmembed 1:7768afcb5df1 5 int n;
icmembed 1:7768afcb5df1 6 Serial OSKAR(PTC4,PTC3);
icmembed 1:7768afcb5df1 7 void delay (int n);
icmembed 1:7768afcb5df1 8 DigitalOut myled(PTB18);
icmembed 1:7768afcb5df1 9 DigitalOut myled2(PTB19);
icmembed 1:7768afcb5df1 10 DigitalOut myled3(PTD1);
icmembed 1:7768afcb5df1 11 DigitalOut m1(PTA1);
icmembed 1:7768afcb5df1 12 DigitalOut m2(PTA2);
icmembed 1:7768afcb5df1 13 DigitalOut md1(PTA4);
icmembed 1:7768afcb5df1 14 DigitalOut md2(PTA5);
icmembed 1:7768afcb5df1 15
beohad 0:feba469f2cf1 16
beohad 0:feba469f2cf1 17 int main() {
icmembed 1:7768afcb5df1 18 myled = 1;
icmembed 1:7768afcb5df1 19 myled2 = 1;
icmembed 1:7768afcb5df1 20 myled3 = 1;
icmembed 1:7768afcb5df1 21 m1 = 1;
icmembed 1:7768afcb5df1 22 m2 = 1;
icmembed 1:7768afcb5df1 23 md1 = 0;
icmembed 1:7768afcb5df1 24 md2 = 1;
icmembed 1:7768afcb5df1 25
icmembed 1:7768afcb5df1 26 OSKAR.baud(9600);
icmembed 1:7768afcb5df1 27 delay(1000);
icmembed 1:7768afcb5df1 28 //OSKAR.printf("Press 'A'\n");
icmembed 1:7768afcb5df1 29
beohad 0:feba469f2cf1 30 while (1) {
icmembed 1:7768afcb5df1 31 char c = OSKAR.getc();
icmembed 1:7768afcb5df1 32 if(c == 'A') {
icmembed 1:7768afcb5df1 33 OSKAR.printf("Led \n");
icmembed 1:7768afcb5df1 34 myled = 1;
icmembed 1:7768afcb5df1 35 myled2 = 0;
icmembed 1:7768afcb5df1 36 myled3 = 1;
icmembed 1:7768afcb5df1 37 m1 = 0;
icmembed 1:7768afcb5df1 38 m2 = 0;
icmembed 1:7768afcb5df1 39 delay(1000);
icmembed 1:7768afcb5df1 40
icmembed 1:7768afcb5df1 41 }
icmembed 1:7768afcb5df1 42
icmembed 1:7768afcb5df1 43 if(c == 'B') {
icmembed 1:7768afcb5df1 44 OSKAR.printf("Led \n");
icmembed 1:7768afcb5df1 45 myled = 0;
icmembed 1:7768afcb5df1 46 myled2 = 1;
icmembed 1:7768afcb5df1 47 myled3 = 0;
icmembed 1:7768afcb5df1 48 m1 = 0;
icmembed 1:7768afcb5df1 49 m2 = 0;
icmembed 1:7768afcb5df1 50
icmembed 1:7768afcb5df1 51 delay(1000);
beohad 0:feba469f2cf1 52 }
icmembed 1:7768afcb5df1 53
icmembed 1:7768afcb5df1 54 if(c == 'D') {
icmembed 1:7768afcb5df1 55 OSKAR.printf("LED Azul green\n");
icmembed 1:7768afcb5df1 56
icmembed 1:7768afcb5df1 57 myled = 0;
icmembed 1:7768afcb5df1 58 myled2 = 0;
icmembed 1:7768afcb5df1 59 myled3 = 1;
icmembed 1:7768afcb5df1 60
icmembed 1:7768afcb5df1 61 delay(1000);
icmembed 1:7768afcb5df1 62
icmembed 1:7768afcb5df1 63
icmembed 1:7768afcb5df1 64
icmembed 1:7768afcb5df1 65
icmembed 1:7768afcb5df1 66
icmembed 1:7768afcb5df1 67
icmembed 1:7768afcb5df1 68 }
icmembed 1:7768afcb5df1 69
icmembed 1:7768afcb5df1 70
icmembed 1:7768afcb5df1 71
icmembed 1:7768afcb5df1 72
icmembed 1:7768afcb5df1 73
icmembed 1:7768afcb5df1 74
icmembed 1:7768afcb5df1 75
icmembed 1:7768afcb5df1 76
icmembed 1:7768afcb5df1 77
icmembed 1:7768afcb5df1 78
icmembed 1:7768afcb5df1 79 if(c == 'H') {
icmembed 1:7768afcb5df1 80 // myled3 = 1;
icmembed 1:7768afcb5df1 81 OSKAR.printf("LED RGB Blanco\n");
icmembed 1:7768afcb5df1 82 myled = 0;
icmembed 1:7768afcb5df1 83 myled2 = 0;
icmembed 1:7768afcb5df1 84 myled3 = 0;
icmembed 1:7768afcb5df1 85
icmembed 1:7768afcb5df1 86 delay(1000);
icmembed 1:7768afcb5df1 87
icmembed 1:7768afcb5df1 88 }
icmembed 1:7768afcb5df1 89
icmembed 1:7768afcb5df1 90
icmembed 1:7768afcb5df1 91 if(c == 'Z') {
icmembed 1:7768afcb5df1 92 OSKAR.printf("LED's Apagados\n");
icmembed 1:7768afcb5df1 93
icmembed 1:7768afcb5df1 94 myled = 1;
icmembed 1:7768afcb5df1 95 myled2 = 1;
icmembed 1:7768afcb5df1 96 myled3 = 1;
icmembed 1:7768afcb5df1 97 m1 = 1;
icmembed 1:7768afcb5df1 98 m2 = 1;
icmembed 1:7768afcb5df1 99 md1 = 1;
icmembed 1:7768afcb5df1 100 md2 = 1;
icmembed 1:7768afcb5df1 101 delay(1000);
icmembed 1:7768afcb5df1 102 }
icmembed 1:7768afcb5df1 103
icmembed 1:7768afcb5df1 104
icmembed 1:7768afcb5df1 105 else if(c=='x'){
icmembed 1:7768afcb5df1 106 myled = 1;
icmembed 1:7768afcb5df1 107 myled2 = 1;
icmembed 1:7768afcb5df1 108 myled3 = 1;}
icmembed 1:7768afcb5df1 109
beohad 0:feba469f2cf1 110 }
icmembed 1:7768afcb5df1 111 }
icmembed 1:7768afcb5df1 112
icmembed 1:7768afcb5df1 113 void delay (int n) {
icmembed 1:7768afcb5df1 114 int i;
icmembed 1:7768afcb5df1 115 int j;
icmembed 1:7768afcb5df1 116 for(i=0;i<n;i++)
icmembed 1:7768afcb5df1 117 for(j=0;j<7000;j++){}
icmembed 1:7768afcb5df1 118 }
icmembed 1:7768afcb5df1 119
icmembed 1:7768afcb5df1 120
icmembed 1:7768afcb5df1 121