I am running a program on my laptop that takes a picture with a webcam every time the "capture" button is pressed using a mouse.
I want to hard wire the mouse to an Arduino so that it can press the button rather than my finger having to do it.
I have run 2 wires from the left click switch and was hoping to find that one side would be connected to ground and that the other would be at 5V, but this is not the case.
Niether side of the switch is connected to Ground.
When not pressed, one side is at 2.5V with respect to the other.
Hi wildbill
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
int potPinValue;
int ledValue;
int frameCounter;
unsigned long previousMillis = 0;
unsigned long captureMillis = 0;
unsigned long strobeMillis = 0;
void setup()
{
pinMode(hallPin, INPUT);
pinMode(capturePin, OUTPUT);
pinMode(strobePin, OUTPUT);
pinMode(strobePotPin, INPUT);
Serial.begin(9600);
int frameCounter = 0;
}
void loop()
{
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;
Serial.println(frameCounter);
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
analogWrite(strobePin, ledValue);
previousMillis = millis();
}
}
lastHallState = hallState;
captureMillis = millis();
if (captureMillis - previousMillis >= capturePulseDuration)
{
digitalWrite (capturePin, LOW);
}
strobeMillis = millis();
if (strobeMillis - previousMillis >= strobePulseDuration)
{
digitalWrite (strobePin, LOW);
}
}