Go Down

Topic: AnalogRead to array then serial print Array (Read 367 times) previous topic - next topic

Crameroni

Hello,
I try to read a sensorvalue between setting a Pin High and Low.
Then write it to an array and at the end of my loop, serial print the whole array with all the informations from analogRead.

Is this possible?
Can you help me in this case?

I attached my code as I worked it out so far.


Quote
int VVRPin = 42;
int VDRPin = 52;
int VSHPin = 34;
int RESPin = 10;
int CLKPin = 26;

int mySensVals[1023];
int val = 0;

void setup() {
  Serial.begin(115200);

  pinMode(VVRPin, OUTPUT);
  pinMode(VDRPin, OUTPUT);
  pinMode(VSHPin, OUTPUT);
  pinMode(RESPin, OUTPUT);
  pinMode(CLKPin, OUTPUT);
  digitalWrite(CLKPin, HIGH);

}

void loop() {
  digitalWrite(RESPin, LOW);
  digitalWrite(RESPin, HIGH);
  delayMicroseconds(7);

  digitalWrite(VVRPin, HIGH);
  digitalWrite(VDRPin, HIGH);
  digitalWrite(VVRPin, LOW);
  delayMicroseconds(195);

  digitalWrite(VDRPin, LOW);
  delayMicroseconds(2);

  digitalWrite(CLKPin, LOW);
  delayMicroseconds(13);
  digitalWrite(CLKPin, HIGH);
  val = analogRead(A0)/3.3;
  mySensVals[0] == val;
  //Serial.println(analogRead(A0));
  digitalWrite(CLKPin, LOW);
  delayMicroseconds(13);
  digitalWrite(CLKPin, HIGH);
  val = analogRead(A0)/3.3;
  mySensVals[1] == val;
  //Serial.println0(analogRead(A0));
  digitalWrite(CLKPin, LOW);
  delayMicroseconds(13);
  digitalWrite(CLKPin, HIGH);
  val = analogRead(A0)/3.3;
  mySensVals[2] ==val;
  //Serial.println(analogRead(A0));
  digitalWrite(CLKPin, LOW);
  delayMicroseconds(13);
  digitalWrite(CLKPin, HIGH);
  val = analogRead(A0)/3.3;


  mySensVals[3] == val;
  for (int i = 0; i < 1023; i++)
   {
    Serial.println(mySensVals);
   }
 
delayMicroseconds(15);

  digitalWrite(VSHPin, HIGH);
  delayMicroseconds(8);
  digitalWrite(VSHPin, LOW);
  delayMicroseconds(7);




  delay(100);
}

Go Up