Reading Digital caliper with Arduino
#21
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

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();
 }
}
Reply
Thanks given by:


Messages In This Thread
RE: Reading Digital caliper with Arduino - by EdK - 03-07-2015, 03:37 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-07-2015, 09:07 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-08-2015, 05:26 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-09-2015, 11:45 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-09-2015, 11:51 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-09-2015, 12:24 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-09-2015, 01:47 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-10-2015, 05:24 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-10-2015, 11:14 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-10-2015, 04:44 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-10-2015, 05:18 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-10-2015, 06:19 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-11-2015, 04:13 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-11-2015, 04:23 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-11-2015, 08:13 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-11-2015, 08:25 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-12-2015, 05:00 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-12-2015, 06:09 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-14-2015, 09:41 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-18-2015, 05:50 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-19-2015, 04:11 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-19-2015, 04:42 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-20-2015, 05:31 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-20-2015, 06:33 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-20-2015, 07:28 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-20-2015, 08:38 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-20-2015, 09:24 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-21-2015, 09:07 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-21-2015, 11:08 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-21-2015, 03:29 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-21-2015, 06:21 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-24-2015, 11:14 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-24-2015, 02:15 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-26-2015, 03:36 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-26-2015, 05:33 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-26-2015, 05:52 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-26-2015, 06:14 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-27-2015, 06:46 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-27-2015, 07:38 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 08:39 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 09:42 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 09:23 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 09:28 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 09:35 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 11:11 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 11:48 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 12:03 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 12:47 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-28-2015, 01:33 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-29-2015, 02:31 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-29-2015, 03:49 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-29-2015, 05:35 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-29-2015, 06:18 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-30-2015, 06:33 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-30-2015, 06:45 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-30-2015, 06:14 PM
RE: Reading Digital caliper with Arduino - by EdK - 03-31-2015, 05:48 AM
RE: Reading Digital caliper with Arduino - by EdK - 03-31-2015, 07:10 PM
RE: Reading Digital caliper with Arduino - by EdK - 04-09-2015, 08:43 PM
RE: Reading Digital caliper with Arduino - by EdK - 04-28-2015, 08:42 AM
RE: Reading Digital caliper with Arduino - by EdK - 08-28-2015, 11:07 AM
RE: Reading Digital caliper with Arduino - by EdK - 08-28-2015, 02:41 PM
RE: Reading Digital caliper with Arduino - by EdK - 09-04-2015, 01:21 PM
RE: Reading Digital caliper with Arduino - by EdK - 09-27-2017, 03:39 PM
RE: Reading Digital caliper with Arduino - by EdK - 09-28-2017, 03:51 PM



Users browsing this thread: 9 Guest(s)