Programming of the ATTINY85 on my camera  

Discuss cameras used for shooting panoramas, virtual tours or 360° videos (GoPros, DSLRs, one shot cams, etc..) and their various accessoires (lenses, monopods/tripods, etc...).
(EN/FR Forum)
no avatar
adawang
New member
 
Topic author
Posts: 2
Likes: 2 posts
Liked in: 0 post
Joined: Tue Dec 06, 2016 7:51 am
Info

Programming of the ATTINY85 on my camera

by adawang » Wed Apr 05, 2017 7:59 am

Hi,

Still working on my camera trap and need to have a very basic program to control two outputs with one input.

It is an infrared camera trap working on a 38khz system, everything is already made except for the programming of the ATTINY85 that will run it.

I need two outputs: when one is high, the other needs to be low and vice versa so that when the beam from the emitter is being received, output 1 is high and output 2 is low. Breaking of the beam would reverse this and when the beam is visible again it would go back to its original state.

The input is from the output of a TSSAL through an optocoupler, so basically a switch.

This is the code I have, and it does not work, and I cannot figure out why.

Code: Select all
const int LED1 = 0;
const int LED2 = 1;
const int SW = 2;

 int val=0;

void setup()
{
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
  pinMode(SW, INPUT);
  }

 void loop()
 {
   val=digitalRead(SW);
if(val==0)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);

}
else

   val=digitalRead(SW);
if(val==1)
{
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,HIGH);

}
 }
 


Something I also would like to see is each time the outputs change, there is a slight delay of maybe 60ms before the output that is being switched off goes to low, but no delay in the other output going to high - so a bit of an overlap. This is important for the camera as it needs 56ms to respond.

Any help is greatly appreciated.

Thanks

User avatar
Christian Stüben
Member
 
Posts: 361
Likes: 3 posts
Liked in: 7 posts
Joined: Tue Jul 03, 2012 5:08 am
Location: Wuppertal, Germany
Info

Re: Programming of the ATTINY85 on my camera

by Christian Stüben » Fri Apr 21, 2017 7:02 am

try to change the loop code:


void loop()
{
if(digitalRead(SW)==0)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2,LOW);
}
else
{
digitalWrite(LED1,LOW);
digitalWrite(LED2,HIGH);
}
}

Do you really need the val variable? is it needed somewhere else in your code?

I dont know the attini and its compilers, and what might be done automatically for a procedure that is called loop.
In my opinion without additional code, it really doesnt loop.

greetings from germany
Chris

User avatar
Christian Stüben
Member
 
Posts: 361
Likes: 3 posts
Liked in: 7 posts
Joined: Tue Jul 03, 2012 5:08 am
Location: Wuppertal, Germany
Info

Re: Programming of the ATTINY85 on my camera

by Christian Stüben » Fri Apr 21, 2017 7:10 am

for the funny delay problem, try to exchange the sequence you set the led to high and low.


Who is online

Users browsing this forum: No registered users and 0 guests