Program to configure the btbee chip on an m3pi over AT commands. Note that the AT hardware switch must be in the AT position for this to work.

Dependencies:   m3pi_ng configure_btbee mbed

Dependents:   configure_btbee

Fork of configure_btbee by Nikolas Goldin

Committer:
friedrich_h
Date:
Sun Jul 31 15:09:46 2016 +0000
Revision:
5:dfe78f25fef8
Child:
6:8c107c6b3433
Ausgabe der Sensordaten der 5 Helligkeitssensoren in kalibrierter und nicht-kalibrierter Form

Who changed what in which revision?

UserRevisionLine numberNew contents of line
friedrich_h 5:dfe78f25fef8 1
friedrich_h 5:dfe78f25fef8 2 #include "mbed.h"
friedrich_h 5:dfe78f25fef8 3 #include "m3pi_ng.h"
friedrich_h 5:dfe78f25fef8 4 #include "btbee.h"
friedrich_h 5:dfe78f25fef8 5
friedrich_h 5:dfe78f25fef8 6 #define SPEED 0.1
friedrich_h 5:dfe78f25fef8 7
friedrich_h 5:dfe78f25fef8 8 #define W_KEY 1
friedrich_h 5:dfe78f25fef8 9 #define A_KEY 2
friedrich_h 5:dfe78f25fef8 10 #define S_KEY 4
friedrich_h 5:dfe78f25fef8 11 #define D_KEY 8
friedrich_h 5:dfe78f25fef8 12 #define R_KEY 16
friedrich_h 5:dfe78f25fef8 13
friedrich_h 5:dfe78f25fef8 14 m3pi myM3pi;
friedrich_h 5:dfe78f25fef8 15
friedrich_h 5:dfe78f25fef8 16
friedrich_h 5:dfe78f25fef8 17 // DigitalOut, DigitalIn, Timer: aus mbed.h
friedrich_h 5:dfe78f25fef8 18 DigitalOut mbed_led[] = {(LED1), (LED2),(LED3), (LED4)};
friedrich_h 5:dfe78f25fef8 19 DigitalOut m3pi_led[] = {(p13), (p14), (p15), (p16), (p17), (p18), (p19), (p20)}; // leds oben: p13-p20 (S. 13, M3PI UG)
friedrich_h 5:dfe78f25fef8 20
friedrich_h 5:dfe78f25fef8 21 //DigitalIn: Input-Objekt, welches mit dem Knopf p21 betätigt wird
friedrich_h 5:dfe78f25fef8 22 DigitalIn m3pi_pb(p21);
friedrich_h 5:dfe78f25fef8 23
friedrich_h 5:dfe78f25fef8 24 //create array for sensors
friedrich_h 5:dfe78f25fef8 25 int raw[5];
friedrich_h 5:dfe78f25fef8 26
friedrich_h 5:dfe78f25fef8 27 //create array for sensors
friedrich_h 5:dfe78f25fef8 28 int cal[5];
friedrich_h 5:dfe78f25fef8 29
friedrich_h 5:dfe78f25fef8 30 int main()
friedrich_h 5:dfe78f25fef8 31 {
friedrich_h 5:dfe78f25fef8 32
friedrich_h 5:dfe78f25fef8 33
friedrich_h 5:dfe78f25fef8 34
friedrich_h 5:dfe78f25fef8 35
friedrich_h 5:dfe78f25fef8 36 // Lichter initialisieren
friedrich_h 5:dfe78f25fef8 37 for (int i = 0; i <4; i++) {
friedrich_h 5:dfe78f25fef8 38 mbed_led[i] = 0;
friedrich_h 5:dfe78f25fef8 39 }
friedrich_h 5:dfe78f25fef8 40 for (int i = 0; i <8; i++) {
friedrich_h 5:dfe78f25fef8 41 m3pi_led[i]=0;
friedrich_h 5:dfe78f25fef8 42 }
friedrich_h 5:dfe78f25fef8 43
friedrich_h 5:dfe78f25fef8 44
friedrich_h 5:dfe78f25fef8 45
friedrich_h 5:dfe78f25fef8 46
friedrich_h 5:dfe78f25fef8 47 // Battery Status:
friedrich_h 5:dfe78f25fef8 48 myM3pi.locate(0,0);
friedrich_h 5:dfe78f25fef8 49 myM3pi.printf("B:%0.3f%V",myM3pi.battery());
friedrich_h 5:dfe78f25fef8 50
friedrich_h 5:dfe78f25fef8 51 wait(0.5);
friedrich_h 5:dfe78f25fef8 52
friedrich_h 5:dfe78f25fef8 53 // myM3pi.sensor_auto_calibrate();
friedrich_h 5:dfe78f25fef8 54
friedrich_h 5:dfe78f25fef8 55
friedrich_h 5:dfe78f25fef8 56
friedrich_h 5:dfe78f25fef8 57
friedrich_h 5:dfe78f25fef8 58
friedrich_h 5:dfe78f25fef8 59 while (true) {
friedrich_h 5:dfe78f25fef8 60
friedrich_h 5:dfe78f25fef8 61 //Initialize sensors to the array
friedrich_h 5:dfe78f25fef8 62
friedrich_h 5:dfe78f25fef8 63 myM3pi.cls();
friedrich_h 5:dfe78f25fef8 64 for (int i = 0; i < 5; i++){
friedrich_h 5:dfe78f25fef8 65 for(int j=0; j<3; j++){
friedrich_h 5:dfe78f25fef8 66 myM3pi.raw_sensor(raw);
friedrich_h 5:dfe78f25fef8 67 myM3pi.calibrated_sensor(cal);
friedrich_h 5:dfe78f25fef8 68 myM3pi.locate(0,0);
friedrich_h 5:dfe78f25fef8 69 myM3pi.printf("r%d: %d",i, raw[i]);
friedrich_h 5:dfe78f25fef8 70 myM3pi.locate(0,1);
friedrich_h 5:dfe78f25fef8 71 myM3pi.printf("c%d: %d",i, cal[i]);
friedrich_h 5:dfe78f25fef8 72 wait(.5);
friedrich_h 5:dfe78f25fef8 73 }
friedrich_h 5:dfe78f25fef8 74 wait(.5);
friedrich_h 5:dfe78f25fef8 75 }
friedrich_h 5:dfe78f25fef8 76
friedrich_h 5:dfe78f25fef8 77
friedrich_h 5:dfe78f25fef8 78 myM3pi.cls();
friedrich_h 5:dfe78f25fef8 79 for(int j=0; j<10; j++){
friedrich_h 5:dfe78f25fef8 80 myM3pi.locate(0,0);
friedrich_h 5:dfe78f25fef8 81 myM3pi.printf("L: %1.2f", myM3pi.line_position());
friedrich_h 5:dfe78f25fef8 82 wait(.5);
friedrich_h 5:dfe78f25fef8 83 }
friedrich_h 5:dfe78f25fef8 84 } // while true
friedrich_h 5:dfe78f25fef8 85
friedrich_h 5:dfe78f25fef8 86 }
friedrich_h 5:dfe78f25fef8 87
friedrich_h 5:dfe78f25fef8 88
friedrich_h 5:dfe78f25fef8 89