+ Post New Thread
Results 1 to 1 of 1
-
13th November 2019, 14:52 #1
- Join Date
- Dec 2011
- Location
- Karachi,Pakistan
- Posts
- 629
- Helped
- 3 / 3
- Points
- 3,886
- Level
- 14
Arduino ADC channels reading approach
Please let me know that I want to display sensors reading, 6 sensors 3 for Voltage sensing and 3 for current sensing CT.
I recently write a code for reading ADC data, please let me know what is good approach for making code.
I mean, code with good sequence for controller, not hanging and not take extra memory.
Please make your valuable suggestions.
Code:int sensorPinV1 = A0; // select the input pin for the potentiometer int sensorPinV2 = A1; // select the input pin for the potentiometer int sensorPinV3 = A2; // select the input pin for the potentiometer int sensorPinA1 = A3; // select the input pin for the potentiometer int sensorPinA2 = A4; // select the input pin for the potentiomete int sensorPinA3 = A5; // select the input pin for the potentiomete int sensorValueV1 = 0; // variable to store the value coming from the sensor int sensorValueV2 = 0; // variable to store the value coming from the sensor int sensorValueV3 = 0; // variable to store the value coming from the sensor int sensorValueA1 = 0; // variable to store the value coming from the sensor int sensorValueA2 = 0; // variable to store the value coming from the sensor int sensorValueA3 = 0; // variable to store the value coming from the sensor void setup() { // declare the ledPin as an OUTPUT: Serial.begin(9600); } void loop() { // read the value from the sensor: sensorValueV1 = analogRead(sensorPinV1); delay(1); sensorValueV2 = analogRead(sensorPinV2); delay(1); sensorValueV3 = analogRead(sensorPinV3); delay(1); sensorValueA1 = analogRead(sensorPinA1); delay(1); sensorValueA2 = analogRead(sensorPinA2); delay(1); sensorValueA3 = analogRead(sensorPinA3); float V1 = sensorValueV1 * (5.0 / 1023.0); Serial.print("V1 VALUE IS = "); Serial.println(V1); float V2 = sensorValueV2 * (5.0 / 1023.0); Serial.print("V2 VALUE IS = "); Serial.println(V2); float V3 = sensorValueV3 * (5.0 / 1023.0); Serial.print("V3 VALUE IS = "); Serial.println(V3); float A1 = sensorValueA1 * (5.0 / 1023.0); Serial.print("A1 VALUE IS = "); Serial.println(A1); float A2 = sensorValueA2 * (5.0 / 1023.0); Serial.print("A2 VALUE IS = "); Serial.println(A2); float A3 = sensorValueA3 * (5.0 / 1023.0); Serial.print("A3 VALUE IS = "); Serial.println(A3); delay(3000); }
IMRAN
-
Advertisement
+ Post New Thread
Please login