So I have a line scan camera attached to my Arduino Mega and I'm trying to send it a digital clock impulse and get an analog output back. The line scan camera is supposed to return 128 pixels.
So far I've been able to send the impulses and get analog values back which I am printing out. However, the values are different every time, which doesn't make sense because the camera didn't move so I assume that it should give back similar numbers.
Also, is there a way to determine what these numbers mean? Is there some way of turning analog signals into color pixels? My ultimate goals is to be able to determine if something has moved through the vision of the line scanner
Here is the datasheet for the line scanner: http://www.farnell.com/datasheets/315815.pdf
Here is my code:
void loop() {
int delayTime = 20;
digitalWrite(syncPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(clockPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(syncPin, LOW);
delayMicroseconds(delayTime);
digitalWrite(clockPin, LOW);
delayMicroseconds(delayTime);
for (int i = 0; i < 128; i++)
{
digitalWrite(clockPin, HIGH);
pixelValue[i] = analogRead(dataPin);
delayMicroseconds(delayTime);
digitalWrite(clockPin, LOW);
delayMicroseconds(delayTime);
}
digitalWrite(clockPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(clockPin, LOW);
delayMicroseconds(delayTime);
for (int j = 0; j < 128; j++)
{
Serial.print("I received: ");
Serial.println(pixelValue[j]);
}
}
analogRead()
causes a delay of at least 104 µs, so thedelayMicroseconds()
right after it is probably not needed.