I am creating an under water motion detected camera for an artwork I am making, and am having trouble integrating the code below into the code that is on this website link. The code in the link is for interfacing a Cam Do (programable control for Go Pro camera) with an Arduino. If anyone might be able to help I would greatly appreciate it.
Thank you,
Carl
laser trip wire code:
/* Project: Laser Tripwire Tutorial
* Written by: Chris Marella
* Date: January 24, 2018
* Version: 1.0
*
*/
//Pin Definitions
const int photo = 7;
const int LED = 9;
void setup() {
//Pin Configurations
//Outputs
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
//Inputs
pinMode(photo, INPUT_PULLUP);
}
void loop() {
//if/else loop checks if photoresistor is high or low
if(digitalRead(photo)==HIGH){
digitalWrite(LED, HIGH);
}else{
digitalWrite(LED, LOW);
}
}
Hello @Karl2022,
May I ask what “photo” is for? A button?
If that’s the case then the code you shared is already included in the code you linked.
This
if(digitalRead(photo)==HIGH){
digitalWrite(LED, HIGH);
}else{
digitalWrite(LED, LOW);
}
Is the same as this:
buttonState = digitalRead(buttonPin); // read the status of the pushbutton
digitalWrite(cameraTriggerPin, buttonState); // send the button status to Blink
The only thing you might want to change is the ledPin
The Arduino’s onboard LED is connected to pin 13 on most models - so you don’t have to worry, the constantLED_BUILTIN
is automatically set to the correct pin. If you want to connect an external LED, then you will need to check your model and change theledPin
value below to an alternate pin if necessary.
const int ledPin = LED_BUILTIN; // the number of the LED pin (pre-defined)
to
const int ledPin = 9; // the number of the LED pin
Hi, and thank you for your response!
“photo” refers to a photoresistor. The code Im trying to integrate is for a laser trip wire, that I found on this website.
Figured it out! All I had to do was add _PULLUP to this section under the void set up.
pinMode(buttonPin, INPUT_PULLUP);
Thanks again for your input!
1 Like