Hello, For my project, I want to be able to measure voltage or resistance from an LDR, and trigger a timer on the PC when it goes over/under a certain value. I would use this in a project for college where I want to measure the period of a swinging object that would interrupt a laser at a certain point. Can anyone suggest how I could achieve this with an Arduino? Thanks.
Why involve the PC when the Arduino can do the whole job?
Really? Well, I was thinking repeat experiments, put the data into a spreadsheet where I can make graphs etc.
I’d like the figures on PC where I can copy them and use them in different programs. Unless I can measure on the Arduino and transfer to the PC after? Could that work, and would the timing be as accurate?
The Arduino can certainly do the measurements, and it would eliminate any latency triggering a timer on the PC. You could output the timings as they are made, and store them on your PC.
Oh awesome, any links or whatever on how I would measure and use the measurement then?
Wire the LDR as a voltage divider with a fixed resistor to one of the analogue input pins. In a loop, do repeated "analogRead" (each one takes about 100 microseconds) until your initial threshold condition is met. Mark the time using "millis", then continue reading until your end condition is me, then mark the time again. Subtract the earlier reading from the later one, and "Serial.println" the result.
About 20 lines of code.