First release.

Dependencies:   FXOS8700CQ SDFileSystem mbed

Final program

  • Controling a robot by Bluetooth, it is capable of making 90° turns and move pre-defined distances.

Code by:

  • Mayumi Hori
  • Sarahí Morán
  • Gerardo Carmona
Committer:
gerardo_carmona
Date:
Fri Nov 07 05:12:50 2014 +0000
Revision:
5:b384cf06de76
Parent:
4:c60636c95b80
Not finished!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gerardo_carmona 2:94059cb643be 1 // ----- Libraries ------------------------------------------------------------------
gerardo_carmona 2:94059cb643be 2 #include "mbed.h"
gerardo_carmona 2:94059cb643be 3 #include "ultrasonic.h"
gerardo_carmona 2:94059cb643be 4
gerardo_carmona 2:94059cb643be 5 // ----- Constants ------------------------------------------------------------------
gerardo_carmona 3:bd16e43ad7be 6
gerardo_carmona 2:94059cb643be 7
gerardo_carmona 2:94059cb643be 8 // ----- I/O Pins -------------------------------------------------------------------
gerardo_carmona 2:94059cb643be 9 AnalogIn ultra_lef(A2);
gerardo_carmona 2:94059cb643be 10 AnalogIn ultra_rig(A3);
gerardo_carmona 2:94059cb643be 11
gerardo_carmona 2:94059cb643be 12 // ----- Others ---------------------------------------------------------------------
gerardo_carmona 2:94059cb643be 13
gerardo_carmona 2:94059cb643be 14
gerardo_carmona 2:94059cb643be 15 // ----- Variables ------------------------------------------------------------------
gerardo_carmona 2:94059cb643be 16 double read_sensor, cm;
gerardo_carmona 2:94059cb643be 17
gerardo_carmona 2:94059cb643be 18 // ----- Functions ------------------------------------------------------------------
gerardo_carmona 2:94059cb643be 19 float ultrasonicos(int sensor){
gerardo_carmona 4:c60636c95b80 20 double inch, volts;
gerardo_carmona 2:94059cb643be 21 if (sensor == ULTRA_R) {
gerardo_carmona 2:94059cb643be 22 read_sensor = ultra_rig; // read analog as a float
gerardo_carmona 2:94059cb643be 23 }else if (sensor == ULTRA_L) {
gerardo_carmona 2:94059cb643be 24 read_sensor = ultra_lef; // read analog as a float
gerardo_carmona 2:94059cb643be 25 }
gerardo_carmona 2:94059cb643be 26 // read_sensor * 3300mv / 6.4 mV/in * 2.54 in/cms
gerardo_carmona 4:c60636c95b80 27 volts = read_sensor * 3300;
gerardo_carmona 4:c60636c95b80 28 inch = volts / 6.4;
gerardo_carmona 4:c60636c95b80 29 cm = inch * 2.54;
gerardo_carmona 2:94059cb643be 30 return cm;
gerardo_carmona 2:94059cb643be 31 }