I have an ATtiny hooked up to two line scan modules. I'm sending digital signals to the line scan modules then receiving the analog output and storing it in an array. I have an if statement that will make the LED on the ATtiny programmer blink when the number are below a certain range (meaning that lens is covered).
Here is my code:
#include <SoftwareSerial.h>
const int rx=0;
const int tx=1;
SoftwareSerial mySerial(rx,tx);
int CLK = 2;
int SI = 1;
int Aout = A3;
int Aout1 = A2;
int LED = 0;
int pixelsArray[128]; //Array to hold the values of the individual pixles.
int pixelsArray1[128];
void outputPixels()
{
for(int j = 0; j < 128; j++)
{
digitalWrite(LED, LOW);
if(pixelsArray[j] < 100)
{
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
}
}
The problem that I am having is that when I test my code with one line scan module it works just fine. You will notice that in the readPixels() I have the statement pixelsArray1[i]=analogRead(Aout1); commented out. However, when I try to use it with two the LED start blinking regardless of how much light is hitting the line scanner.
The strange thing is that EVEN when I comment out the digitalWrite(LED, HIGH); statement in the outputPixels() method...THE LED STILL BLINKS!!!
Since the ATtiny does not support URT and can't use the console in Arduino I have no idea how to debug this. Does anyone here have any clue what is wrong?
Here is the datasheets
ATtiny Programmer: https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/?_ga=1.59946280.467360091.1464906372