Menu

Someone Convert C Codes Arduino Assembly Language Atmel Studio 7 Const Int Flowsensor 2 Fl Q43877764

Can someone convert these C++ codes (Arduino) intoassembly language (Atmel Studio 7)?

const int flowSensor         = 2; // Flow rate sensor pin

const int oneB               = 7; // OR-Gate IC pins

const int oneA               = 8;

const int oneY               = 9;

const int tempSensor         = A3; // Temperature sensor pin

volatile int flowFrequency    = 0; // Flowpulse

unsigned int flowRate         = 0;// Variable for flow rate (L/Hour)

unsigned int flowThreshold    = 191; //Maximum safe flow rate

unsigned long currentTime     = 0; // Timesince UNO is ON

unsigned long cloopTime       = 0;

bool type                    = true; // true = Temperature, false =Flow

bool output                  = false; // Output variable for OR-GateIC 

int tempVoltage              = 0; // Output variable for temperature sensor

double tempCelcius           = 0; // Variable for temperature (degC)

double tempThreshold         = 28.70; // Maximum safe temperature

void flow() {flowFrequency++;}         // Interrupt function

void temperature() {

    tempVoltage =analogRead(tempSensor);

    tempCelcius = tempVoltage *5;      // 5V

    tempCelcius = tempCelcius /1024;   // 1024 bits

    tempCelcius = tempCelcius -0.5;    // Offset

    tempCelcius = tempCelcius *100;    // Temperature value (degC) 

    Serial.print(tempCelcius);

    Serial.println(” degC”);

}

void waterFlow() {

    currentTime = millis();

    if (currentTime >=(cloopTime + 1000)) {

        cloopTime =currentTime;        // Update cloopTime

        //Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in+/- 3% range)

        //(Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour 

        flowRate =((flowFrequency * 60) / 7.5);

        flowFrequency =0;              // Reset pulsecounter

        Serial.print(flowRate,DEC);

        Serial.println(“L/hour”);

    }

}

void setup() {

    pinMode(tempSensor,INPUT);

    pinMode(flowSensor,INPUT);

    pinMode(oneA, OUTPUT);

    pinMode(oneB, OUTPUT);

    Serial.begin(9600);                // Begin serialmonitor

    attachInterrupt(0, flow,RISING);   // Setup interrupt

    sei();                            // Enable interrupt (Set I bit)

    currentTime = millis();            // Input time since UNO isON

    cloopTime = currentTime;

}

// Parameter check function for temperature and flowrate

// Check type: true = temperature, false = flowrate

void parameterCheck(bool type, double data, doublethreshold) {

    // Compares the currentparameter data with its corresponding threshold

    bool parameterExceed = (data>= threshold);

    if (parameterExceed) {

        if(type) {                                //Temperature exceeded

            digitalWrite(oneB,HIGH);

            Serial.println(“TEMPERATURE:HIGH”);

        } else{                                   //Flow rate exceeded

            digitalWrite(oneA,HIGH);

            Serial.println(“FLOW      : HIGH”);

        }

    } else {

        if(type) {                                // Normaltemperature

            digitalWrite(oneB,LOW);

            Serial.println(“TEMPERATURE:LOW”);

        } else{                                   //Normal flow rate

            digitalWrite(oneA,LOW);

            Serial.println(“FLOW      : LOW”);

        }

    }

}

void loop() {

    temperature();                                    // Inputand calculate temperature

    waterFlow();                                      //Input and calculate flow rate

    parameterCheck(true,tempCelcius, tempThreshold);   // Check temperature

    parameterCheck(false,flowRate, flowThreshold);     // Check flow rate

    output = digitalRead(oneY);                       // Warning data

    if (output)Serial.println(“WARNING”);             // (Temperature OR flow rate) = HIGH

    elseSerial.println(“NORMAL”);                     // (Temperature OR flow rate) =LOW

    Serial.println(” “);                              // Print a blank line

    delay(5000);                                      //Next-batch-input delay time

}

We are using water flow sensor and temperature sensor.Those two will be input to the ATMega328P in Arduino UNO.

Expert Answer


Answer to Can someone convert these C++ codes (Arduino) into assembly language (Atmel Studio 7)? const int flowSensor = 2; // Flow…

OR