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: SerialMultiByte QEI TFmini IRsensor
Diff: main.cpp
- Revision:
- 0:d789af71fbc6
- Child:
- 1:6ae7ff29d054
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Aug 26 08:44:58 2019 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "IRsensor.h"
+#include "TFmini.h"
+#include "QEI.h"
+#include "SerialMultiByte.h"
+#include "pinconfig.h"
+
+union UnionBytes{
+ uint8_t bytes[28];
+ float IRdistance[7]; //0~1
+ uint32_t TFdistance[7]; //2~3
+ uint32_t pulses[7]; //4~6
+};
+
+IRsensor ir[] = {
+ IRsensor(IR_0),
+ IRsensor(IR_1)
+};
+
+TFmini tf[] = {
+ TFmini(TF0_TX, TF0_RX),
+ TFmini(TF1_TX, TF0_RX)
+};
+
+QEI loli[] = {
+ QEI(encoder_0A, encoder_0B, NC, 100, QEI::X4_ENCODING),
+ QEI(encoder_1A, encoder_1B, NC, 100, QEI::X4_ENCODING),
+ QEI(encoder_2A, encoder_2B, NC, 100, QEI::X4_ENCODING)
+};
+
+SerialMultiByte serial(mainTX, mainRX);
+
+int main()
+{
+ UnionBytes bytedata;
+ for(int i=0; i<28; i++){
+ bytedata.bytes[i] = 0;
+ }
+ for(int i=0; i<2; i++){
+ ir[i].startAveraging(10);
+ }
+ while (true) {
+ for(int i=0; i<2; i++){
+ bytedata.IRdistance[i] = ir[i].get_Averagingdistance();
+ }
+ for(int i=0; i<2; i++){
+ bytedata.TFdistance[i+2] = tf[i].getDistance();
+ }
+ for(int i=0; i<3; i++){
+ bytedata.pulses[i+4] = loli[i].getPulses();
+ }
+ serial.sendData(bytedata.bytes, 28);
+ }
+}
+