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 Motor LSM9DS1_Library_cal PinDetect HC_SR04_Ultrasonic_Library
Diff: main.cpp
- Revision:
- 6:d25157f50f14
- Parent:
- 5:85951362fd6d
- Child:
- 7:5667ce16d526
diff -r 85951362fd6d -r d25157f50f14 main.cpp
--- a/main.cpp Wed Nov 21 19:43:30 2018 +0000
+++ b/main.cpp Wed Nov 21 20:32:01 2018 +0000
@@ -14,14 +14,8 @@
//---------------------|
// Debug LED pin:
//DigitalOut led(p25);
-
-// Motor Power Control pins:
-/*
-DigitalOut Ctrl1(p29);
-DigitalOut Ctrl2(p30);
-PinDetect sw(p20);
-*/
-
+DigitalIn sw(p20);
+Serial pc(USBTX,USBRX);
// Setup Motor Driver pins:
Motor Lfront(p21, p6, p5); // PWM to p21, forward to p6, reverse to p5...
Motor Rfront(p22, p8, p7); // PWM to p22, forward to p8, reverse to p7...
@@ -133,54 +127,15 @@
//---------------|
int main() {
// Use internal pullup for the switch:
- //sw.mode(PullUp);
-
- // Delay for initial pullups to take effect:
- //wait(0.01);
-
- // Initialize and calibrate the IMU:
- /*
- LSM9DS1 imu(p28, p27, 0xD6, 0x3C); // SDA to p28, SCL to p27...
- imu.begin();
- imu.calibrate(1);
- imu.calibrateMag(0);
-
- imu.readGyro();
- start = imu.gz;
- */
-
+ sw.mode(PullUp);
// Initialize the Ultrasonic Sensor:
usensor.startUpdates();
// Initialize the Timer:
t.start();
+ pc.printf("sw is : %d", sw);
+ while(!sw) {
- while(1) {
- // Toggle motor battery banks:
- /*
- if (!sw == 1) {
- Ctrl1 = 1;
- Ctrl2 = 1;
- wait(0.2);
- }
- else {
- Ctrl1 = 0;
- Ctrl2 = 0;
- wait(0.2);
- }
- */
-
- // Read IMU gyro:
- //while(!imu.gyroAvailable());
- //imu.readGyro();
- //heading = imu.calcGyro(imu.gz);
- // X - imu.calcGyro(imu.gx)
- // Y - imu.calcGyro(imu.gy)
- // Z - imu.calcGyro(imu.gz)
-
- //if (heading > 90) {led=1;} else {led=0;}
-
- // Read Ultrasonic Sensor:
usensor.checkDistance();
wait(0.1);