mbed Demo Display that shows several of the features
Dependencies: MSCUsbHost mbed Servo SRF08
main.cpp
00001 #include "mbed.h" 00002 #include "SRF08.h" 00003 #include "Servo.h" 00004 #include "ID12RFID.h" 00005 00006 DigitalOut led1(LED1); 00007 DigitalOut led2(LED2); 00008 PwmOut led3(LED3); 00009 00010 SRF08 srf08(p28, p27, 0xE0); // Define SDA, SCL pin and I2C address 00011 PwmOut meter (p22); 00012 Servo servo (p21); 00013 AnalogIn pot (p18); 00014 ID12RFID rfid (p10); 00015 AnalogIn th (p19); 00016 LocalFileSystem fs ("fs"); 00017 00018 int main() { 00019 00020 FILE *fp = fopen("/fs/hello.txt","w"); 00021 fprintf(fp,"Hello World!\n"); 00022 fclose(fp); 00023 00024 while (1) { 00025 00026 // Check to see if an RFID tag has been presented, if so, display it 00027 if (rfid.readable()) { 00028 printf("ID Tag : %d\n",rfid.read()); 00029 led1 = !led1; 00030 } 00031 00032 // If the middle pot is more than half way 00033 // read and display from the Ultrasonic range finder 00034 if (th.read() > 0.5) { 00035 float measure = srf08.read(); 00036 printf("Measured range : %.2f cm\n",measure); 00037 meter = 1.0 - (measure/44.0); 00038 led2 = !led2; 00039 } 00040 00041 // Move the servo to reflect the pot 00042 servo = pot.read(); 00043 led3.write(pot.read()); 00044 wait(0.1); 00045 } 00046 }
Generated on Thu Jul 14 2022 22:43:26 by 1.7.2