TITLE: study arduino program
on this week im study about my arduino program. Arduino is the main brain of my project so i need to study more deeply on this program. based on my study i can find my solution to read my data from the input source and output source.This data so important this is because the data will send to my visual basic software so that i can show my data in graphically.
void loop()
{
Serial.print("$");
Serial.print("Read");
Serial.print(",");
val=analogRead(A0);//This divider module will divide the measured voltage by 5, the maximum voltage it can measure is 25V.
temp=val/40.92; //
val=temp;//
Serial.print(val);
Serial.print(",");
//Serial.print("Volt,");
//delay(30);
a
total= total - readings[index];
readings[index] = analogRead(A1); //Raw data reading
readings[index] = (511-readings[index])*5/1024/0.04;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
total= total + readings[index];
index = index + 1;
if (index >= numReadings)
index = 0;
average = total/numReadings; //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)
currentValue= average;
Serial.print(currentValue);
Serial.print(",");
//Serial.print("A,");
//delay(30);
power = val*currentValue;
Serial.print(power);
Serial.print(",");
//Serial.print("Watt,");
valout = analogRead(A4);
/*tempout = valout * (1.0 / 1024);
Serial.print(tempout);
Serial.print("Volt(OUT)");*/
tempout=valout/40.92; //
valout=tempout;//
Serial.println(valout);
//Serial.print(",");
//Serial.println("Volt(OUT)");
//delay(30);
delay(100);
}
No comments:
Post a Comment