Lab06 - oppgave 4. Funksjon printf-statement som forteller deg når POTen gir optimal spenning

Dependencies:   mbed

main.cpp

Committer:
fkgjh
Date:
2015-10-08
Revision:
0:8f2651efac77

File content as of revision 0:8f2651efac77:

#include "mbed.h"

DigitalOut Vcc(PA_0);
AnalogIn aInn(PA_1);
DigitalOut Gnd(PA_4);

int main() 
{   
    Vcc=1;
    Gnd=0;
    
    while(1)
    {
       float voltage;
       voltage=aInn.read()*3.3f;
       
    if(voltage<1)
        printf("For lav spenning! V= %.3f\n", voltage);
        
    else if(voltage<2 || voltage>1)
        printf("Riktig spenning :-) V= %.3f\n", voltage);
        
    else if(voltage>3)
        printf("For hoy spenning! V= %.3f\n", voltage);
        
        wait_ms(600);
        
        
        //printf("AvgV: %.3f Curent: %.3f Min: %.3f Max: %.3f Max-Min: %.3f\r\n",sum, voltage, maxVoltage, minVoltage, maxVoltage-minVoltage);
        //wait_ms(500);
    }
}