Cadenscores
Published © GPL3+

A treat dispensing dog-cam

I have my phone that shows me what a camera is seeing, I can turn the flashlight on that is sensed by a photoresistor, which triggers a treat.

BeginnerProtip587
A treat dispensing dog-cam

Things used in this project

Hardware components

Photo resistor
Photo resistor
×1
Arduino UNO
Arduino UNO
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Alfred

Story

Read more

Schematics

Photoresistor to servo.

When the light sensor senses a bright light it will spin a servo motor.

Code

Photoresistor to servo.

C/C++
If the light sensor reaches a certain value, then it will spin a servo motor.
//include the servo library

#include  <Servo.h>

//create a servo object called servo1 Servo servo1;
Servo servo1;

void setup() { 

// put your setup code here, to run once:

// set the servo pin, pin 9, as an servo output pin servo1.attach(9); }
 servo1.attach(9);
 }
void loop() {
  // put your main code here, to run repeatedly:

int lightValue = analogRead(A0);

// map the light readings to the angle possible by the servo motor lightValue = map (lightValue, 0, 1023, 0, 180);
lightValue = map(lightValue, 0, 1023, 0, 180);

if(lightValue>99
)
{
servo1.write(30);
}
  else
    
servo1.write(0);
}

Credits

Cadenscores
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.