0

Project: The Arduino Oscilloscope - published in The MagPi No. 71 July 2018

This is my first Arduino project! I'm porting over the sketch "Gather_A0.ino" but I'm encountering compile errors: Error message: 'ADCSRA' was not declared in this scope. What am I missing?

Error message:


Arduino: 1.8.12 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
D:\Arduino & Raspberry Pi\Oscilloscope\Arduino_Scope\Software\Gather_A0\sketch_apr09a\sketch_apr09a.ino: In function 'void setup()':
sketch_apr09a:15:3: error: 'ADCSRA' was not declared in this scope
   ADCSRA = (ADCSRA & 0xf8) | 0x04; // set 16 times division
   ^
D:\Arduino & Raspberry Pi\Oscilloscope\Arduino_Scope\Software\Gather_A0\sketch_apr09a\sketch_apr09a.ino: In function 'void trigger()':
sketch_apr09a:58:4: error: expected 'while' before '{' token
   }{
    ^
sketch_apr09a:58:4: error: expected '(' before '{' token
sketch_apr09a:58:4: error: expected primary-expression before '{' token
sketch_apr09a:58:4: error: expected ')' before '{' token
sketch_apr09a:58:4: error: expected ';' before '{' token
sketch_apr09a:60:1: error: expected '}' at end of input
 }
 ^
exit status 1
'ADCSRA' was not declared in this scope

  • ADSCRA is a register involved in analog inputs on an AVR board. The analog input on an ESP8266 works completely differently. You'll have to figure out what the AVR code does and then figure out how to do the same thing on the ESP. It's not going to be a simple "change this to that" sort of solution. – Delta_G Apr 10 at 2:00
  • I see, my best solution is to order a real Arduino board. I will do that. Thank you -Delta. – Projectsfan Apr 10 at 2:18
  • The article is using an Arduino Nano. You can get the source code without the bugs you've introduced at github.com/Grumpy-Mike/Mikes-Pi-Bakery/tree/master/… – Dougie Apr 10 at 7:03
  • the esp8266 like to hang if you read its ADC more than ~1000 times per sec. – dandavis Apr 10 at 16:00

Your Answer

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

Browse other questions tagged or ask your own question.