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: N5110 ShiftReg Tone mbed
Fork of 1620_Project_Template by
ModeC.cpp
00001 #include "ModeC.h" 00002 00003 void mode_C() 00004 { 00005 00006 lcd.clear(); 00007 lcd.printString("Mode C",0,0); 00008 lcd.refresh(); 00009 wait_ms(250); // small delay to prevent previous press being detected again 00010 00011 while (button_c.read() == 0) { 00012 // code goes in here - this acts like the main while(1) loop 00013 00014 lcd.clear(); 00015 00016 lcd.printString("Mode C",0,0); 00017 00018 float pot0_val1 = pot_0.read(); 00019 float dist_cm = pot0_val1*200; 00020 printf("Gap distance = %.0f cm\n",dist_cm); 00021 00022 speaker.init(); 00023 00024 float t = dist_cm*19/4000+0.05; 00025 speaker.play(1000,t); 00026 // printf("%0.2f\n",t); 00027 00028 00029 float W1=pot0_val1*-75+75; 00030 lcd.drawRect(3,27,75,12,FILL_TRANSPARENT); 00031 lcd.drawRect(3,27,W1,12,FILL_BLACK); 00032 00033 if (dist_cm<20) { 00034 blue_led.write(1); 00035 red_led.write(0); 00036 green_led.write(1); 00037 } else { 00038 blue_led.write(1); 00039 red_led.write(1); 00040 green_led.write(1); 00041 } 00042 00043 00044 int arrow[5][20] = { 00045 { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 }, 00046 { 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 }, 00047 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, 00048 { 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 }, 00049 { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0 }, 00050 }; 00051 lcd.drawSprite(30,20,5,20,(int *)arrow); 00052 00053 00054 00055 lcd.refresh(); 00056 wait(t); 00057 } 00058 00059 }
Generated on Wed Jul 13 2022 07:12:38 by
1.7.2
