Demo entry 6354554

v

   

Submitted by anonymous on Apr 08, 2017 at 11:17
Language: C. Code size: 1.3 kB.

//Vital capacity measurement.
int vital()
{
    float vout;
    float n;
    float n1;
    float ab;
    float v;
    float i=0;
    int s=0;
    float vital;
    pc.printf("Blowing into a tube after 5 seconds, please.\n");     //Remind and count down.
    dig1=0;dig2=1;dig3=1;dig4=1;
    for (s=5; s>=0; s--)
    {    
         wait(1);
         pc.printf(" %d \n", s);
         switch (s)
                {
                case 1: seg= 0x06;  break;
                case 2: seg = 0x5B; break;
                case 3: seg= 0x4F;  break;
                case 4: seg = 0x66;  break;
                case 5: seg = 0x6D; break;
                default: seg=0x00;
                }
      }
    pc.printf("Start.\n\n");
    wait(1.5);
    vout=Ain*3.3;
    n=(vout/5-0.04)/0.09+0.25;
    if(n<0.05)
  {pc.printf("Can not senses your breathing!\n\n");}           //Detection if belowing or not
   for( ;n>0.05;)
  {   
       wait(0.5);
       i=i+0.5;       //Total time
     vout=Ain;
      n=(vout/5-0.04)/0.09+0.4;
       n1=n+101.3;
       ab=sqrt(0.0026*n1);
       v=(ab/1.3)*1000;
       vital=v*i;
       pc.printf("Present gas volume: %1.2fml \n\n", vital);
  }
    pc.printf("Your vital capacity is %1.2f ml.\n\n" , vital);   // Result
    return 0;
} 

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).