![](/media/cache/profiles/639b1cbf061045ad1032ab9068c20b28.jpg.50x50_q85.jpg)
Ultrasonico
main.cpp@0:892136a9b384, 2014-10-14 (annotated)
- Committer:
- DnPlas
- Date:
- Tue Oct 14 23:30:29 2014 +0000
- Revision:
- 0:892136a9b384
Mensaje
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DnPlas | 0:892136a9b384 | 1 | /*El siguiente programa leerá e imprimirá valores obtenidos por |
DnPlas | 0:892136a9b384 | 2 | un sensor ultrasónico Ping ))) de Parallax. |
DnPlas | 0:892136a9b384 | 3 | ARDUINO - FRDM http://www.haoyuelectronics.com/ebay/FRDM-KL25Z/5.jpg |
DnPlas | 0:892136a9b384 | 4 | FRDM PIN http://developer.mbed.org/media/uploads/rikabel/kl25z-pinout-revised.jpg |
DnPlas | 0:892136a9b384 | 5 | Daniela Plascencia*/ |
DnPlas | 0:892136a9b384 | 6 | |
DnPlas | 0:892136a9b384 | 7 | //-------LIBRARIES------- |
DnPlas | 0:892136a9b384 | 8 | #include "mbed.h" |
DnPlas | 0:892136a9b384 | 9 | #include "Ping.h" |
DnPlas | 0:892136a9b384 | 10 | |
DnPlas | 0:892136a9b384 | 11 | //---------I/O PINS-------- |
DnPlas | 0:892136a9b384 | 12 | Ping sensor(D7); |
DnPlas | 0:892136a9b384 | 13 | Serial pc(USBTX, USBRX); |
DnPlas | 0:892136a9b384 | 14 | |
DnPlas | 0:892136a9b384 | 15 | //--------VARIABLES-------- |
DnPlas | 0:892136a9b384 | 16 | float distancia=0; |
DnPlas | 0:892136a9b384 | 17 | |
DnPlas | 0:892136a9b384 | 18 | //--------MAIN------------- |
DnPlas | 0:892136a9b384 | 19 | int main () |
DnPlas | 0:892136a9b384 | 20 | { |
DnPlas | 0:892136a9b384 | 21 | while (1) { |
DnPlas | 0:892136a9b384 | 22 | sensor.Send(); |
DnPlas | 0:892136a9b384 | 23 | wait_ms(30); |
DnPlas | 0:892136a9b384 | 24 | distancia = sensor.Read_cm(); |
DnPlas | 0:892136a9b384 | 25 | pc.printf("Distancia: %f\n", distancia); |
DnPlas | 0:892136a9b384 | 26 | wait(1); |
DnPlas | 0:892136a9b384 | 27 | } |
DnPlas | 0:892136a9b384 | 28 | } |
DnPlas | 0:892136a9b384 | 29 |