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.
Fork of Ultralydsensor by
Brede.cpp
- Committer:
- bredeh
- Date:
- 2016-04-01
- Revision:
- 1:cdf97a56d4d4
- Parent:
- 0:27c5b713c538
- Child:
- 2:c4eb242c1b43
File content as of revision 1:cdf97a56d4d4:
#include "mbed.h"
DigitalOut TriggerPin(p17); //Sender signal
DigitalOut EchoPin(p18); //Motar signal
DigitalIn Br(p15);
DigitalOut myled(LED1);
int valg;
float tid;
Timer timer;
Serial pc(USBTX, USBRX);
Timer echo; //Timer for avlesing av echosignal.
main()
{
pc.printf("Tast 1 for avstandsmaaling: ");
pc.printf("Tast 2 for bevegelsesmaaling: ");
pc.printf("Tast 3 for hastighetsmaaling: ");
pc.scanf("%d",&valg);
}
switch meny()
{
case 1:
timer.start()
triggerfunc();
if(EchoPin==0)
{
timer.stop();
pc.printf(" tiden lyden brukte er %f.4",timer.read();)
tid=timer.read()* 340) / 100 /2;
pc.printf(" Avstanden er %f.4",tid);
}
/* Sender ut ett trigger signal på 10us */
void triggerfunc()
{
TriggerPin = 1;
wait(10u);
TriggerPin = 0;
}
