Page 484 - MDP2020-1
P. 484

|    인천전자마이스터고등학교  ·············································································································
            478



            float  voMeasured=  0.0;
            float  calcVolatage  =  0.0;
            float  dustDensity  =  0.0;



            void  setup(){
                    Serial.begin(9600);
                    pinMode(ledPower,OUTPUT);

            }


            void  loop(){
                    digitalWrite(ledPower,  LOW);  //power  on  the  LED
                    delayMicroseconds(samplingTime);



            vo  Measured  =  analogRead(measurePin);//  read  the  dust  value


            delayMicroseconds(deltaTime);
            digitalWrite(ledPower,HIGH);  //  turn  the  LED  off

            delayMicroseconds(sleepTime);


            //  0~5  V  mapped  to  0~1023  integer  values
            //  recover  voltage
            calcVoltage  =  voMeasured  *  (5.0/1024.0);



            dustDensity  =  0.17  *  calcVoltage  -  0.1;


            Serial.print("Raw  Signal  Value  (0-1023):  ");
            Serial.print(voMeasured);



            Serial.print("  -  Voltage  :  ");
            Serial.print(calcVoltage);


            Serial.print("  -  Dust  desity:  :  ");
            Serial.print(dustDensity);



            delay(1000);
            }
   479   480   481   482   483   484   485   486   487   488   489