I'm noticing my data is not changing with an Arduino Pro Trinket. The data is being sent from a spectrometer. More light= higher numbers. The code I am using works fine with an Arduino Uno (same number of values coming in, but with a range going from 95 to 1000) while the Trinket ranges from 173-184ish.
Could this be an FTDI connection issue? (It is kind of poorly soldered)
Or is the Trinket not capable of gathering these numbers?
Do I have to change something my code?
Code is here:
/*
* Macro Definitions
*/
#define SPEC_TRG A0
#define SPEC_ST A1
#define SPEC_CLK A2
#define SPEC_VIDEO A3
#define SPEC_CHANNELS 288 // New Spec Channel
uint16_t data[SPEC_CHANNELS];
void setup(){
//Set desired pins to OUTPUT
pinMode(SPEC_CLK, OUTPUT);
pinMode(SPEC_ST, OUTPUT);
digitalWrite(SPEC_CLK, HIGH); // Set SPEC_CLK High
digitalWrite(SPEC_ST, LOW); // Set SPEC_ST Low
Serial.begin(9600); // Baud Rate set to 9600
}
/*
* This functions reads spectrometer data from SPEC_VIDEO
* Look at the Timing Chart in the Datasheet for more info
*/
void readSpectrometer(){
int delayTime = 1; // delay time
// Start clock cycle and set start pulse to signal start
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
digitalWrite(SPEC_ST, HIGH);
delayMicroseconds(delayTime);
//Sample for a period of time
for(int i = 0; i < 3000; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//Set SPEC_ST to low
digitalWrite(SPEC_ST, LOW);
//Sample for a period of time
for(int i = 0; i < 85; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//One more clock pulse before the actual read
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
//Read from SPEC_VIDEO
for(int i = 0; i < SPEC_CHANNELS; i++){
data[i] = analogRead(SPEC_VIDEO);
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//Set SPEC_ST to high
//digitalWrite(SPEC_ST, HIGH);
//Sample for a small amount of time
for(int i = 0; i < 7; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
}
/*
* The function below prints out data to the terminal or
* processing plot
*/
void printData(){
for (int i = 0; i < SPEC_CHANNELS; i++){
Serial.print(data[i]);
Serial.print(',');
}
Serial.print("\n");
}
void loop(){
readSpectrometer();
printData();
delay(1000);
}