I need help in the code please
Moderators: adafruit_support_bill, adafruit

I need help in the code please

by SEMA on Mon Apr 23, 2012 2:45 am

Hi,
I have created this code to make the servo press to camera to take a picture each X min and i add to my circle 2 pushbuttons. I need to add LCD but i have no idea how can i add it to my code to count and read the picture and time.. can some one help me on it please!

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position
const int buttonPin = 2; //sets pin 2 as button
const int buttonPin2 = 3; //sets pin 3 as button
const int ledPin = 13; // sets pin 13 as LED for testing purposes
int buttonState = 0; //sets button 1 as off
int buttonState2 = 0; // sets button 2 as off

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
pinMode (buttonPin, INPUT); // sets button as input
pinMode (ledPin, OUTPUT); // sets led as output
myservo.write(90); // starts servo at 90 degrees
}

void loop()
{
buttonState = digitalRead(buttonPin);
buttonState2 = digitalRead(buttonPin2);

if (buttonState == HIGH)
{
digitalWrite(ledPin, HIGH);
for(pos = 90; pos < 110; pos += 1) // goes from 90 degrees to 110 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable ‘pos’

delay(15); // waits 15ms for the servo to reach the position

}

delay (1500);

for(pos = 110; pos>=90; pos-=1) // goes from 110 degrees to 90 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
else {
digitalWrite(ledPin, LOW);
}

if (buttonState2 == HIGH)
{

digitalWrite(ledPin, HIGH);
for(pos = 90; pos >=70; pos -= 1) // goes from 90 degrees to 70 degrees in steps of 1 degree
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
delay (1500);
for(pos = 70; pos <=90; pos+=1) // goes from 70 degrees to 90 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
else {
digitalWrite(ledPin, LOW);
}
}
SEMA
 
Posts: 4
Joined: Mon Apr 23, 2012 2:33 am

Re: I need help in the code please

by adafruit_support_bill on Mon Apr 23, 2012 6:41 am

I need to add LCD but i have no idea how can i add it to my code to count and read the picture and time.

First you need to decide what kind of LCD. There are many to choose from: http://www.adafruit.com/category/63

The character LCDs are simpler to work with than the graphical ones.
The easiest of all is the LCD shield.
User avatar
adafruit_support_bill
 
Posts: 30125
Joined: Sat Feb 07, 2009 10:11 am

Re: I need help in the code please

by SEMA on Mon Apr 23, 2012 2:32 pm

Hi,

Here The link for the LCD which I have.

http://www.sparkfun.com/products/10768

Please help me!
SEMA
 
Posts: 4
Joined: Mon Apr 23, 2012 2:33 am

Re: I need help in the code please

by franklin97355 on Mon Apr 23, 2012 3:54 pm

Have you tried the SparkFun site for help? They should support that display. It looks like the have something on github
User avatar
franklin97355
 
Posts: 5038
Joined: Mon Apr 21, 2008 2:33 pm

Re: I need help in the code please

by SEMA on Mon Apr 23, 2012 4:26 pm

No I did not.
Because my problem only in the code! I have not a strong background in programing. my code is work but I need to add this object.
SEMA
 
Posts: 4
Joined: Mon Apr 23, 2012 2:33 am

Re: I need help in the code please

by adafruit_support_bill on Mon Apr 23, 2012 5:14 pm

Our libraries work with the displays we sell and we can offer support for those.
Sparkfun has a support forum too and they should be able to help you with the display you bought from them.
User avatar
adafruit_support_bill
 
Posts: 30125
Joined: Sat Feb 07, 2009 10:11 am

Re: I need help in the code please

by SEMA on Mon Apr 23, 2012 11:29 pm

Ok thanks.
SEMA
 
Posts: 4
Joined: Mon Apr 23, 2012 2:33 am