#include <Streaming.h>
#include "StopWatch.h"
#include <Albert.h>
#include "avdweb_AnalogReadFast.h"

const byte adcPin = A1; 

void setup(void) 
{ Serial.begin(9600);
  Serial << "\nanalogRead_10bit us1 analogRead_12bit us2 analogReadFast_10bit us3 analogReadFast_12bit us4";
  for(int i=0; i<10; i++) testAnalogRead();

void testAnalogRead()
{ static Stopwatch Stopwatch(micros); 

  int adc1 = analogRead(adcPin); // default resolution 10bit 425us on SAMD21 
  stopwatch.stop(); int t1 = stopwatch.interval;

  int adc2 = analogRead(adcPin); // 425us on SAMD21 
  stopwatch.stop(); int t2 = stopwatch.interval;

  int adc3 = analogReadFast(adcPin); // 23us on SAMD21  
  stopwatch.stop(); int t3 = stopwatch.interval;

  int adc4 = analogReadFast(adcPin); // 24us on SAMD21 
  stopwatch.stop(); int t4 = stopwatch.interval;

  Serial << endl << adc1, t1, adc2, t2, adc3, t3, adc4, t4;
  analogReadResolution(10); // restore default

void loop(void) 

Hi I have to run this code in the Arduino Zero. When I try to compile this code it throws the following error:


In file included from /Users/RAJU/Documents/Arduino/Test_AnalogReadFast_SAM/Test_AnalogReadFast_SAM.ino:2:0:
/Users/RAJU/Documents/Arduino/libraries/Streaming/Streaming.h:102:15: warning: unused parameter 'arg' [-Wunused-parameter]
 inline Print &operator <<(Print &obj, _EndLineCode arg) 

/Users/RAJU/Documents/Arduino/Test_AnalogReadFast_SAM/Test_AnalogReadFast_SAM.ino: In function 'void testAnalogRead()':
Test_AnalogReadFast_SAM:17: error: 'Stopwatch' does not name a type
 { static Stopwatch Stopwatch(micros); 
Test_AnalogReadFast_SAM:20: error: 'stopwatch' was not declared in this scope
exit status 1
'Stopwatch' does not name a type

Any helps are greatly appreciated

  • what debugging have you done? ..... did you try anything before posting the question? – jsotola Jun 8 '18 at 17:29
  • it should be static StopWatch stopwatch(MICROS); – Juraj Jun 8 '18 at 18:40

The compiler doesn't know the type Stopwatch. You have a typo there. A short look into the header file (StopWatch.h) shows you, that it is StopWatch and not Stopwatch. You need a big W there.

Next time first try to investigate yourself. Obviously you didn't do anything before asking here. Next time try it and then, if you cannot find the problem, then write in your question what you have tried.

I was able to compile the following program in my Arduino IDE for Arduino/Genuino Zero:

#include "StopWatch.h"

void setup() {
  static StopWatch Stopwatch(StopWatch::MICROS);

void loop() {

The StopWatch library comes from this Github page. It is the same, that you linked within your other language with the same code, so I assume, that you use it.

For future questions: It is better to directly provide links to all used libraries, that are not part of the Arduino IDE.

  • No, I tried many times. I tried StopWatch also. It throws the same error for StopWatch and Stopwatch. – Raju KC Jun 8 '18 at 18:27
  • For me it compiles if I also write MICROS instead of micros. If it doesn't for you, please write a minimal working example, that shows this error, with no other library included than StopWatch – chrisl Jun 8 '18 at 18:49
  • Are you also using the Arduino Zero ? – Raju KC Jun 8 '18 at 18:54
  • Could you please send me the link for the StopWatch library that you have used? Thank you for your comment. – Raju KC Jun 8 '18 at 19:07
  • @RajuKC: Added the compilable code and the library link to the answer – chrisl Jun 8 '18 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.