I have this code in total below
Code:
// ===================================================================================
// = library includes =
// ===================================================================================
#include <avr/eeprom.h>
#include <Servo.h>
#include <Time.h>
// ===================================================================================
// = Servo object instatiation =
// ===================================================================================
Servo oServo;
// ===================================================================================
// = Global variable to hold time and interval =
// ===================================================================================
time_t NextEvent;
#define Interval 600 //this is 600 seconds or 10 minutes
// ===================================================================================
// = Array to hold servo positions =
// = these are the servo PWM signals that you will need to tune to your servo =
// ===================================================================================
byte ServoPos[] = {0,51,102,204,255};
// ===================================================================================
// = Structure to hold state =
// ===================================================================================
struct ServoParams_t
{
byte Position;
int Direction;
} ServoParams;
// ===================================================================================
// = Setup code =
// ===================================================================================
void setup()
{
oServo.attach(9); // Attach the oServo object to use pin 9
LoadSettings(); // Read from the EEPORM
if(ServoParams.Direction > 1) ServoParams.Direction = 1; // just a bit of safety in the case of the EEPROM value being out of range
if(ServoParams.Direction < -1) ServoParams.Direction = -1; // just a bit of safety in the case of the EEPROM value being out of range
NextEvent = now() + (Interval); // Set the first interval time
}
// ===================================================================================
// = Main Program loop =
// ===================================================================================
void loop()
{
if(now() >= NextEvent)
{
NextEvent = now() + (Interval); // Set the next interval time
ServoParams.Position += ServoParams.Direction; // Increment or decrement the servo posistion array pointer
if (ServoParams.Position >= 4 || ServoParams.Position <= 0) ServoParams.Direction = -ServoParams.Direction; // check for range end and swap direction
oServo.write(ServoPos[ServoParams.Position]); // Write value to oServer Object
SaveSettings(); // Store state in EEPROM
}
}
// ===================================================================================
// = EEPROM Storage Handlers =
// ===================================================================================
void LoadSettings(void)
{
eeprom_read_block((void*)&ServoParams, (void*)(sizeof(ServoParams)), sizeof(ServoParams));
}
void SaveSettings(void)
{
eeprom_write_block((const void*)&ServoParams, (void*)(sizeof(ServoParams)), sizeof(ServoParams));
}
Returns these errors.....
pondo:1: error: function definition does not declare parameters
pondo:19: error: 'time_t' does not name a type
pondo.ino: In function 'void setup()':
pondo:48: error: 'NextEvent' was not declared in this scope
pondo:48: error: 'now' was not declared in this scope
pondo.ino: In function 'void loop()':
pondo:57: error: 'now' was not declared in this scope
pondo:57: error: 'NextEvent' was not declared in this scope
I have been told to install the "time" library and have done that and can see it in library's but do I have to add this to the code or does it find it automatically.
I am a total Newby so please excuse my dumbness.
Can some one give me a laymans account of what I need to do.
Thanks
Wayne