Odpověď na: dalkova spoust pro zrcadlovku
Úvodní stránka › Fórum › Vaše projekty › Arduino › dalkova spoust pro zrcadlovku › Odpověď na: dalkova spoust pro zrcadlovku
kod pro transmitter :
#include <VirtualWire.h>
#define PIN_MOTION 2
#define PIN_LIGHT 13
#define PIN_TX 12
char *message;
void setup() {
pinMode(PIN_LIGHT, OUTPUT);
pinMode(PIN_MOTION, INPUT);
digitalWrite(PIN_LIGHT, LOW);
vw_set_ptt_inverted(true);
vw_set_tx_pin(PIN_TX);
vw_setup(2000);
delay(1000);
}
void loop(){
byte input = digitalRead(PIN_MOTION);
if (input == HIGH){
digitalWrite(PIN_LIGHT, HIGH);
message = „1“ ;
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx();
delay(10);
}
else{
digitalWrite(PIN_LIGHT, LOW);
}
}
kod pro reciever :
/*———————————————————————————-
Motion Activated DSLR Shutter Remote
Receiver Sketch (433mHz Serial RX)
Written By: Angelo Casimiro (ASCAS/ TechBuilder)
Date Written: October 18, 2014
Pin Configuration:
– Digital#12 of Arduino to Data Out of RX module
– Digital#11 of Arduino to IR LED
———————————————————————————-*/
#include <multiCameraIrControl.h>
#include <VirtualWire.h>
Canon D5(11);
void setup()
{
vw_set_ptt_inverted(true);vw_set_rx_pin(12);
vw_setup(2000);vw_rx_start();unsigned int data = 0;
pinMode(13, OUTPUT);
pinMode(11, OUTPUT);
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)){
if(buf[0]==’1′){
digitalWrite(13,1);
D5.shutterNow();
}
if(buf[0]==’0′){
digitalWrite(13,0);
}
}
}