Linear Array

Hello.

I make a project for my school where I have to capture light by means of a linear array.
My problem with this is that the linear array is actually supposed to deliver values ​​between 0-255 (0-> no light, 255-> maximum brightness, for example, when a laser lights up directly). But I get no values ​​as a result.

Could someone please help me? (I'm sorry if there are mistakes in my statement.)

Linear Array: TSL from the company AMS

#include <SoftwareSerial.h>
#include <math.h>
// Parameter des Aufbaus
double l1= 100;
double l2 = 70;
double z1=100;
double z2 = 70;
double d = 3;

float alpha1;
float alpha2;

unsigned char value= 0; // unsigned --> nur positive Werte

// Pinbelegung

SoftwareSerial mySerial(10, 11); // RX, TX
const int SCKPin = 9;
//Receive --> Empfangen --> SDIN --> PIN 10
//Transmit --> Senden --> SDOUT --> Pin 11

void setup() {
  // Arduino konfigurierem --> Was für eine Art für Übertragung
  Serial.begin(9600);
  mySerial.begin(9600); // baud --> Bit/Sekunde

  pinMode(SCKPin, LOW);

}

void loop() { // loop wird von außen aufgerufen. nach beendigung wird sie erneut aufgerufen

  //MOSI
 mySerial.write(0x1b);
 mySerial.write(0x1b); // alternative zum interface initailization (statt IRESET --> 3 RESET)
 mySerial.write(0x1b);
  
  delay(100);
  
  Serial.write(0x1b); //Reset Befehl // code interpretiert er als Befehl (muss man jedesmal machen, weil in den Pixel ein Wert gespeichert ist!)
  delay(100);
  
  //Verstärkung und Offset // Man kann eine Verstärkung für jeden Pixel einstellen. Jedes Bit entspricht bei einer Maximalen verstärkung 300 elektronen 
  for (int i = 0; i<6; i+=2){ // i ist die adresse und entspricht Hexadezimalen Wert i = 0 --> 0x00
    mySerial.write(i+0x40); // REGWrite 0x40 --> möchte auf die Adresse schreiben (0x60 --> möchte von der Ardesse lesen)
    mySerial.write(10); //Wert für Offset
    mySerial.write(i+1+0x40);
    mySerial.write(31); //Wert für die Verstärkung aus Tabelle Seite 3 (maximale Verstärkung)
  }
  
  //Serial.write(0x1f);
  //Serial.write(0);
  
  mySerial.write(0x08); // Start Integration (Licht aufnahme) 
  delay (1000);
  mySerial.write(0x10); // Stopt Integration (Licht aufnahme wird beendet --> ADC)
  delay (1000);
  mySerial.write(0x02); // Read Pixel Data (liest die werte und schickt diese anschließend zum arduino)
  value = mySerial.read();
  mySerial.print(value, HEX);
  //Formatieren
  mySerial.write(value);
  delay (100);


 //MISO
 for (int i = 0; i<103; i++){ // Wert: Anzahl an Licht die in diesem Pixel empfangen worden ist. Liefert immer werte wegen Umgebungslicht
  value = mySerial.write(1); // 
 }
 
 
  //Schwellwert definieren, damit man den Unetrschied zwischen Laserlicht und Umgebungslicht wahrnehmen kann
  mySerial.end();
  delay(1000);  

  
}

Please provide a link to the actual hardware used (AMS is producing several products that has TSL in it's name). Also provide schematics or a wiring diagram of your setup.

You have the comments 'MISO' and 'MOSI' in your sketch which are names of SPI signal pins but you're using SoftwareSerial. I didn't found a TLS that accepts UART style commands at 9600 baud so I get the impression you either didn't read the datasheet of your sensor or you didn't understand it.

I wonder if the OP is using this array TSL3301 Linear Sensor Array –with Analog-to-Digital Converter | ams, which has a most unusual "UART-like" serial interface. From the data sheet:

The serial interface follows a USART format, with start bit, 8 data
bits, and one or more stop bits. Data is clocked in synchronously
on the rising edge of SCLK and clocked out on the falling edge
of SCLK.

Seems interesting, as it has a built in ADC, but obviously, it will not work with SoftwareSerial, which does not provide a synchronous clock signal.

.

Cross post in the German section of the forum.

https://forum.arduino.cc/index.php?topic=521756.0

jremington:
I wonder if the OP is using this array TSL3301 Linear Sensor Array –with Analog-to-Digital Converter | ams, which has a most unusual "UART-like" serial interface. From the data sheet:

Seems interesting, as it has a built in ADC, but obviously, it will not work with SoftwareSerial, which does not provide a synchronous clock signal.

.

That's EXACTLY how the USART chips from the 1970's, 80's. 90's worked.

Paul