Arduino Digital Indicator Code
Arduino Digital Indicator Code
Arduino Digital Indicator Code
I tried the PIC method on the same Indicator, and it just didn't work out for me.
I wound up coding up a arduino nano to do the same thing, and it was much
easier/faster/cheaper.
Here's the code:
//UART Speed
#define UARTBaudRate 9600
//Data Format
#define DATA_BITS_LEN 24
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
void setup(){
//set ADC prescale to 16 (set ADC clock to 1MHz)
//this gives as a sampling rate of ~77kSPS
sbi(ADCSRA, ADPS2);
cbi(ADCSRA, ADPS1);
cbi(ADCSRA, ADPS0);
Serial.begin(UARTBaudRate);
}
void loop(){
//read in data
while( bit_count < DATA_BITS_LEN && timeout_counter < 50 ){
clk=(analogRead(ClkPin) > ADC_Threshold);
clock_lpv=clk;
}
//Serial.println();
//if (timeout_counter >= 50){
//Serial.println("timed out");
//}
total += (bit1*1);
total += (bit2*2);
total += (bit3*4);
total += (bit4*8);
total += (bit5*16);
total += (bit6*32);
total += (bit7*64);
total += (bit8*128);
total += (bit9*256);
total += (bit10*512);
total += (bit11*1024);
total += (bit12*2048);
total /= 100;
//Serial.print("total:");
Serial.println(total);
delay(100);
It works, cost under $10 to make (assuming you already have the indicator).
Anyways, your tutorial really helped me and I thought I'd pay it forward.