What is wrong with my Code!

The arduino program doesn’t like my code and I do not understand why?

It uses the same library as mem said at http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1263305457 and I have followed his code. I probably look like a complete buffoon saying I don’t know why my code is wrong but I actually don’t, and nobody but the internet and forums can help me where I live, so sorry for bothering and asking lots of questions.

The code is attempting to run a program that takes pictures of things moving past it between 1-3pm.
I have listened to the Ideas of others on this and they suggested a Real time clock, but while looking at RTC code I found Such a thing as a Alarm Library. This is what I have attempted to use for timekeeping, but I have a feeling that the only way of keeping time is with an RTC, and that that is why my program doesn’t work.

Maybe you could have a look at it.

#include <Time.h>
#include <TimeAlarms.h>
#include <Servo.h>

Servo myservo;

void setup()
  setTime(7,56,0,8,12); // Set the Time
  Alarm.alarmrepeat(13,00,0,CameraCapture); // Set the code to go off at 1:00pm

// Set up the Alarms and the time thing

void CameraCapture // What to do on this alarm
  if <=(13,00,0) && <=(15,00,0) //If After 1pm and before 3pm
  // Do the ping Stuff

const int pingPin = 7;

void setup() {

void loop()
  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);

  long microsecondsToInches(long microseconds)
  return microseconds / 74 / 2;

long microsecondsToCentimeters(long microseconds)
  return microseconds / 29 / 2;

// Ping stuff now working
// And
   if (inches <= 110) // If ping measures an object within 110 Inches
    myservo.write(0);   // move the servo to activate camera button
    myservo.write(20);    // move the servo to back to default position
} // Finish the CameraCapture code.


You need to say what this code actually does. Will it compile?
Will it run but not do what you want?

Setting the pin mode in a loop is wrong it should be in the setup. It will not stop the code from running but shows it is poorly written.

  if <=(13,00,0) && <=(15,00,0) //If After 1pm and before 3pm

I think the “will it compile?” question is firmly answered there.

Your loop is also missing at least one closing brace “}” - you can’t declare functions in the middle of another function (at least, not in this version of C)