Narcolepsy

Hello
I am getting some errors with a program.
Errors:

sketch_nov14a.cpp: In function ‘void loop()’:
sketch_nov14a:61: error: ‘Narcoleptic’ was not declared in this scope

Here is my code:

#include <Servo.h> 
#include <Narcoleptic.h>

/*
A library that allows the microcontroller to go into standby
in times of inactivity, saving energy.
*/
 
Servo myservo;
int Value;
int Center=105; 

/*
The variable Center represents the value of centering of
servo continuous rotation. In my case is 105.
*/

void setup() { 
  Serial.begin(9600);
  myservo.attach(9); // Connect the servo to pin 9
}

void loop() {
  int sensorValue = analogRead(A0);  // Read the value of the sensor LDR left
  int sensorValue2 = analogRead(A1); // Read the value of the sensor LDR right
  
  Value=(sensorValue-sensorValue2)/10;  

   /*
   Calculates the difference between the two sensors and divides them for 10,
   in this way a difference of 10 is equal to 1, a difference
   of 53 is equivalent to 5 and so on
   */
  
  if (Value==0) myservo.detach(); else myservo.attach(9); 
   
  
  if (Value>10) Value=10; 
  if (Value<-10) Value=-10;
  
   /*
   Limits the maximum difference between -10 and + 10
   (to avoid excessive speed)
   */
  
  Serial.println(Value); // Debug - Displays the value on the serial
  myservo.write(Center+Value); 

   /*
   If the value of Value is positive, move the Servo DX, if it is negative SX.
   The speed sould be directly proportional to the absolute value of Value
   */
  
  Narcoleptic.delay(15);

   /*
 I'm using this to save energy.
    */
   
}

Ultimately, I’m trying to make a servo follow the sun.
My Fritzing sketch is attached. Please help. Thanks!

  if (Value==0) myservo.detach(); else myservo.attach(9);

Here's one error.

Mark

ebkapalka:
Hello
I am getting some errors with a program.
Errors:

sketch_nov14a.cpp: In function ‘void loop()’:
sketch_nov14a:61: error: ‘Narcoleptic’ was not declared in this scope

Here is my code:

#include <Servo.h> 

#include <Narcoleptic.h>

/*
A library that allows the microcontroller to go into standby
in times of inactivity, saving energy.
*/

Servo myservo;
int Value;
int Center=105;

/*
The variable Center represents the value of centering of
servo continuous rotation. In my case is 105.
*/

void setup() {
  Serial.begin(9600);
  myservo.attach(9); // Connect the servo to pin 9
}

void loop() {
  int sensorValue = analogRead(A0);  // Read the value of the sensor LDR left
  int sensorValue2 = analogRead(A1); // Read the value of the sensor LDR right
 
  Value=(sensorValue-sensorValue2)/10;

/*
   Calculates the difference between the two sensors and divides them for 10,
   in this way a difference of 10 is equal to 1, a difference
   of 53 is equivalent to 5 and so on
   /
 
  if (Value==0) myservo.detach(); else myservo.attach(9);
   
 
  if (Value>10) Value=10;
  if (Value<-10) Value=-10;
 
   /

   Limits the maximum difference between -10 and + 10
   (to avoid excessive speed)
   */
 
  Serial.println(Value); // Debug - Displays the value on the serial
  myservo.write(Center+Value);

/*
   If the value of Value is positive, move the Servo DX, if it is negative SX.
   The speed sould be directly proportional to the absolute value of Value
   */
 
  Narcoleptic.delay(15);

/*
I’m using this to save energy.
    */
   
}




Ultimately, I'm trying to make a servo follow the sun.
My Fritzing sketch is attached. Please help. Thanks!

Looks like the narcoleptic library isn’t installed properly.

Code:

if (Value==0) myservo.detach(); else myservo.attach(9);

Here's one error.

Mark

Where? Not including braces and not indenting isn't an error.

Did you restart the IDE after installing the library? Did you install the library at all?