Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:832c213480a8
- Parent:
- 0:6bf5faf294b7
- Child:
- 2:7cb9c966a781
--- a/main.cpp Thu Feb 16 14:08:34 2017 +0000
+++ b/main.cpp Thu Feb 16 15:19:30 2017 +0000
@@ -1,40 +1,44 @@
#include "mbed.h"
+#define MAX 0x0A
-#define MAX 0x0A
DigitalOut led_1(LED1); //program running.
DigitalOut led_2(LED2); //sensors operating.
DigitalOut led_3(LED3); //is moving.
DigitalOut led_4(LED4); //is complete.
-DigitalOut Bit1(p25);
-DigitalOut Bit2(p24);
-DigitalOut Bit3(p23);
+
+DigitalOut Bit1(p25); // mux/ pins
+DigitalOut Bit2(p24); //
+DigitalOut Bit3(p23); //
int rawUS_data[5]={0,0,0,0,0}; //raw data{chan1,chan2,chan3,chan4,chan5}
-int US1_mean[MAX]={0,0,0,0,0,0,0,0,0,0};
-int US2_mean[MAX]={0,0,0,0,0,0,0,0,0,0};
+
+int US1_mean[MAX]={0,0,0,0,0,0,0,0,0,0}; // Structures holding recently recorded distances for each respective
+int US2_mean[MAX]={0,0,0,0,0,0,0,0,0,0}; // ultrasonic sensor.
int US3_mean[MAX]={0,0,0,0,0,0,0,0,0,0};
int US4_mean[MAX]={0,0,0,0,0,0,0,0,0,0};
int US5_mean[MAX]={0,0,0,0,0,0,0,0,0,0};
void setActiveUS(int chan);
+
int getPing(void);
int main() {
int iCount = 0;
int measured = 0;
+
while(iCount <= 5){
setActiveUS(iCount);
measured = getPing();
rawUS_data[iCount] = measured;
- }
+ }
+
US1_mean[0]=rawUS_data[0];
US2_mean[0]=rawUS_data[1];
US3_mean[0]=rawUS_data[2];
US4_mean[0]=rawUS_data[3];
US5_mean[0]=rawUS_data[4];
-
-
+
}
void setActiveUS(int chan){
@@ -59,8 +63,8 @@
//ultrasonic 5
break;
- }
}
+}
int getPing(void){
int result=0;
@@ -68,5 +72,6 @@
//return measured value
- return result;
-}
\ No newline at end of file
+ return result; //should just do "return [operation that gives result];" for efficiency
+}
+