Hoi,
Ik heb een wiel-encoder : kubler incremental encoder met 250 pulses per draai.
Ik wil deze verbinden met de arduino Uno. Wat hij moet doen/doorgeven is dat elke x m1 (2,5 meter) er een trigger gaat naar een camera. "maak foto"
Op de camera heb ik kabel blauw (opto input) en groen (opto ground). Hiermee kan ik de camera triggeren om een foto te maken.
Echter als ik deze nu rechtstreeks de wiel-encoder op de camera aansluit maakt hij super veel foto's. Niet goed dus.
Ik wil de Arduino Uno gebruiken om de pulses te reguleren. Lees, instellen dat hij elke 15 omwentelingen van de encoder 1 pulse doorgeeft.
Ik heb nu de code van Benny-Tommy Eriksen gebruikt, zie onderstaand.
Hoe kan ik op de Arduino Uno een output op twee pins zetten om een trigger door te geven aan de camera??
Wie kan mij helpen?
*/
// Encoder connect to digitalpin 2 and 3 on the Arduino.
volatile unsigned int counter = 0; //This variable will increase or decrease depending on the rotation of encoder
void setup() {
Serial.begin (9600);
//Setting up interrupt
//A rising pulse from encodenren activated ai0(). AttachInterrupt 0 is DigitalPin nr 2 on moust Arduino.
attachInterrupt(0, ai0, RISING);
//B rising pulse from encodenren activated ai1(). AttachInterrupt 1 is DigitalPin nr 3 on moust Arduino.
attachInterrupt(1, ai1, RISING);
}
void loop() {
// Send the value of counter
Serial.println (counter);
}
void ai0() {
// ai0 is activated if DigitalPin nr 2 is going from LOW to HIGH
// Check pin 3 to determine the direction
if(digitalRead(3)==LOW) {
counter++;
}else{
counter--;
}
}
void ai1() {
// ai0 is activated if DigitalPin nr 3 is going from LOW to HIGH
// Check with pin 2 to determine the direction
if(digitalRead(2)==LOW) {
counter--;
}else{
counter++;
}
}
