Skip to main content
Arduino

Return to Question

added 10 characters in body
Source Link

I am trying to use the sleep function in leulieu of delay(); butdelay(), but when I include sleep();sleep(), I get Sweep.cpp:60:10: error: ‘sleep’ was not declared in this scopeSweep.cpp:60:10: error: ‘sleep’ was not declared in this scope

I read some place, about #include <avr/sleep.h>#include <avr/sleep.h> but that is a fail.

#include <avr/sleep.h>
void setup() { 
}
void loop() {
 digitalWrite(13, HIGH); // set the LED on
 sleep(1); // wait for a second
 digitalWrite(13, LOW); // set the LED off
 sleep(1000); // wait for a second
}

I was able to locate sleep.h,sleep.h:

$ locate sleep.h | grep avr
/usr/lib/avr/include/avr/sleep.h

soSo then I started reading avr/sleep.havr/sleep.h, and it seems like ImI'm doing it right, according to the examples. SoSo, why might this be failing?

I am trying to use the sleep function in leu of delay(); but when I include sleep(); I get Sweep.cpp:60:10: error: ‘sleep’ was not declared in this scope

I read some place, about #include <avr/sleep.h> but that is a fail.

#include <avr/sleep.h>
void setup() { 
}
void loop() {
 digitalWrite(13, HIGH); // set the LED on
 sleep(1); // wait for a second
 digitalWrite(13, LOW); // set the LED off
 sleep(1000); // wait for a second
}

I was able to locate sleep.h,

$ locate sleep.h | grep avr
/usr/lib/avr/include/avr/sleep.h

so then I started reading avr/sleep.h, and it seems like Im doing it right, according to the examples. So, why might this be failing?

I am trying to use the sleep function in lieu of delay(), but when I include sleep(), I get Sweep.cpp:60:10: error: ‘sleep’ was not declared in this scope

I read some place, about #include <avr/sleep.h> but that is a fail.

#include <avr/sleep.h>
void setup() { 
}
void loop() {
 digitalWrite(13, HIGH); // set the LED on
 sleep(1); // wait for a second
 digitalWrite(13, LOW); // set the LED off
 sleep(1000); // wait for a second
}

I was able to locate sleep.h:

$ locate sleep.h | grep avr
/usr/lib/avr/include/avr/sleep.h

So then I started reading avr/sleep.h, and it seems like I'm doing it right, according to the examples. So, why might this be failing?

Source Link
j0h
  • 902
  • 4
  • 13
  • 30

error: ‘sleep’ was not declared in this scope

I am trying to use the sleep function in leu of delay(); but when I include sleep(); I get Sweep.cpp:60:10: error: ‘sleep’ was not declared in this scope

I read some place, about #include <avr/sleep.h> but that is a fail.

#include <avr/sleep.h>
void setup() { 
}
void loop() {
 digitalWrite(13, HIGH); // set the LED on
 sleep(1); // wait for a second
 digitalWrite(13, LOW); // set the LED off
 sleep(1000); // wait for a second
}

I was able to locate sleep.h,

$ locate sleep.h | grep avr
/usr/lib/avr/include/avr/sleep.h

so then I started reading avr/sleep.h, and it seems like Im doing it right, according to the examples. So, why might this be failing?

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /