This is the same project that you commented on a week or so ago, the one about the conversion of 8mm cine film to a digital format.
A hall effect sensor signals when the frame is ready for capture, I then planned to send a 5v pulse from an Arduino pin to the modified mouse. Its important that I am able to set the duration of the mouse click, 15ms seeems about optimal.
I have orered an Arduino Micro which I understand can send mouse like signals to the PC, but I dont know if its possible to set click duration so I would still like to learn how to use my modified mouse.
Here is my latest code. I have sorted out the millis isssue and that part of it works well now.
// this constant won't change:
const int hallPin = 4; // the pin that the hall sensor is attached to
const int capturePin = 3; // the pin that the LED is attached to
const int strobePin = 6;
const int strobePotPin = A7;
const int capturePulseDuration = 15;
const int strobePulseDuration = 15;
// Variables will change:
int hallState = 0; // current state of the hall sensor
int lastHallState = 0; // previous state of the hall sensor
unsigned long previousMillis = 0;
unsigned long captureMillis = 0;
unsigned long strobeMillis = 0;
int frameCounter = 0;
hallState = digitalRead(hallPin); // read the hall input pin:
if (hallState != lastHallState) // compare the hallState to its previous state
if (hallState == LOW)
digitalWrite (capturePin, HIGH); //start the capture pulse
frameCounter = frameCounter + 1;
potPinValue = analogRead(strobePotPin); // read the strobe brightness value from the pot
ledValue = map(potPinValue, 0, 1023, 0, 255); //Mapping the Values between 0 to 255 from 0 -255 using the analogwrite funtion
previousMillis = millis();
lastHallState = hallState;
captureMillis = millis();
if (captureMillis - previousMillis >= capturePulseDuration)
digitalWrite (capturePin, LOW);
strobeMillis = millis();
if (strobeMillis - previousMillis >= strobePulseDuration)
digitalWrite (strobePin, LOW);