03-09-2015, 11:45 AM
Chuck,
I don't get a compiler error when I insert the line of code Arvid suggested. Here's my complete program. I don't have the board yet, it should be here by Wednesday.
Ed
I don't get a compiler error when I insert the line of code Arvid suggested. Here's my complete program. I don't have the board yet, it should be here by Wednesday.
Ed
Code:
//Simple Digital Calliper Reader
//See http://j44industries.blogspot.com/
// Pin Declarations
int dataIn = 16;
int clockIn = 15;
// Variables
int clock = 1;
int lastClock = 1;
unsigned long time = 0;
unsigned long timeStart = 0;
int out = 0;
void setup() {
// Pin Set Up
pinMode(dataIn, INPUT_PULLUP);
pinMode(clockIn, INPUT_PULLUP);
Serial.begin(115200);
Serial.println("Ready: ");
}
void loop(){
lastClock = clock;
clock = digitalRead(clockIn);
if (lastClock == 1 && clock == 0){
out = digitalRead(dataIn)+digitalRead(dataIn)+digitalRead(dataIn); // Tripple sampling to remove glitches
Serial.println(micros());
if((micros() - time) > 800){
Serial.println(" ");
}
else if((micros() - time) > 400){
Serial.print(" ");
}
if (out > 1){
Serial.print("1");
}
else{
Serial.print("0");
}
Serial.print(",");
time = micros();
}
}