Show Posts
|
|
Pages: [1]
|
|
1
|
Using Arduino / Interfacing w/ Software on the Computer / Re: Arduino Pro Sends Data to the serial port for only a limited amount of time...
|
on: August 11, 2011, 10:37:03 am
|
|
const int sensor1 = A0; // pin that the sensor is attached to const double offSetCorrection = .170;
void setup() { Serial.begin(9600);//Sets up COM port // Serial.println("Power Monitering System!");
}
void loop() {
int endTime = millis() + 21.66;
double sensor1Sum = 0; int count = 0;
while (endTime > millis()){ int value = analogRead(sensor1); double sensedVoltage = value * .0049; double current = ((sensedVoltage-2.5) / .1); sensor1Sum = (sensor1Sum + (current * current)); count++; } double RMS = sqrt((sensor1Sum/count)); if ( RMS < offSetCorrection){ RMS = 0; } Serial.print(":"); Serial.print(RMS, 4); delay(1000);
}
|
|
|
|
|