Hi, I'm working with this sensor and in the oscilloscope I'm getting the correct signal however I am unable to do an analog read, I'm guessing because it's going to fast. Any suggestions?
#define sh 0x01 //D53
#define clock1 0x02 //D52
#define clock2 0x10 //D10
#define rs 0x20 //D11
#define bt 0x40 //D12
void tcdsetup () {
DDRB = B11111111; //OUTPUT D8-D13
}
unsigned int tcdout[1047];
void tcd_read() {
PORTB = sh|clock1;
PORTB= clock1;
for (int i = 0; i < 1047; ++i) {
PORTB = clock1;
PORTB = rs | clock1;
PORTB = rs | bt | clock1;
PORTB = bt | clock1;
PORTB = bt | clock2;
PORTB = clock2;
PORTB = rs | clock2;
PORTB = rs | bt | clock2;
PORTB = bt | clock2;
PORTB = bt | clock1;
int v= analogRead(A1);
tcdout[i]=v;
}
}
void setup() {
tcdsetup();
Serial.begin(9600);
}
void loop() {
tcd_read();
tcd_read();
for (int i = 0; i < 1047; ++i) {
Serial.println(tcdout[i]);
}
}