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:
- 7:b8a29109ae84
- Parent:
- 6:e15a4b0c8cbf
- Child:
- 8:1af0c46d21d2
--- a/main.cpp Sat Mar 11 13:45:04 2017 +0000
+++ b/main.cpp Sat Mar 11 14:09:00 2017 +0000
@@ -9,16 +9,18 @@
DigitalOut led_3(LED3); //is moving.
DigitalOut led_4(LED4); //is complete.
-DigitalOut Bit1(p25);
-DigitalOut Bit2(p24);
-DigitalOut Bit3(p23);
-DigitalOut Trig(p6);
-DigitalIn Echo(p7);
+DigitalOut Bit1(p25); // US mux value
+DigitalOut Bit2(p24); // US mux value
+DigitalOut Bit3(p23); // US mux value
+DigitalOut Trig(p6); // outgoing pin
+DigitalIn Echo(p7); // recieving pin
-PwmOut steering(p21);
-PwmOut velocity(p22);
+AnalogIn temperature(p20); // temperature read pin
-Timer US;
+PwmOut steering(p21); // steering modification
+PwmOut velocity(p22); // velocity modification
+
+Timer US; // <-- Iain, comment pls
//global variable dec
int rawUS_data[5]={0,0,0,0,0}; //raw data{chan1,chan2,chan3,chan4,chan5}
@@ -32,10 +34,11 @@
//function constructs
void setActiveUS(int chan); //select sensor
-int getPing(void); //get measurement
-void turn(float s); //turn car -1 left 0 centre 1 right
-void drive(float v); //drive -1 reverse 1 forward
-void stop(void);
+int getPing(void); //get US measurement
+void turn(float s); //turn car -1 left 0 centre 1 right
+void drive(float v); //drive -1 reverse 1 forward
+void stop(void); //stop the car
+void getTemp(void);
int measurement_mean(int chan);
int main() {
@@ -171,6 +174,21 @@
return;
}
+void getTemp(void) { // Reads ambient temperature from Variable Resistor
+ telemUpdate(temperature); // calls telemUpdate to write ambient temp to file
+ return; // <-- Unfinished, needs algorithm for voltage to temp conversion
+}
+
+void telemUpdate(float steer, float speed) { // Opens set file for logging, appends some data, then returns.
+ stream << "steer:" << steer << " speed:" << speed << "\n"; // This method is only called for speed and heading changes.
+ return;
+}
+
+void telemUpdate(float temp) { // Opens set file for logging, appends some data, then returns.
+ stream << "temp:" << temp << "\n"; // This method is only called for ambient temperature readings.
+ return;
+}
+
int measurement_mean(int chan){
int value=0;
int sum = 0;