How to fix this, I have Elegoo Uno R3
OP: Missing "void" ?
@Coding Badly: LOL!
Looks like the compiler doesn't like the ISR declaration. It could be that the function above that is not correctly formed.
Danois90:
OP: Missing "void" ?
That is certainly a good guess. And I appreciate your attempt to help.
But, the ISR macro includes the return type...
ISR(ADC_vect)
{
}
void setup( void )
{
}
void loop( void )
{
}
Sketch uses 464 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Yep, figured that out. The problem is most likely located in the (super-secret un-posted) code above the ISR
+1
Adventures in Babysitting - Babysitting Blues
"Nobody Leaves This Place Without Singing The Blues"
This is whole code my bad for sloppy question.
This is code, I just copy it form net
/*
OScope
Oscilloscope based on arduino and Processing.
http://yaab-arduino.blogspot.it/p/oscope.html
*/
#include <avr/interrupt.h>
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define NUMSAMPLES 1024
#define INPUTPIN A0
byte buf[NUMSAMPLES];
int x=0;
unsigned long t, t0;
void setup()
{
// initialize the serial port to 230400 baud, if you have problems lower it to 115200
Serial.begin(230400);
ADCSRA = 0; // clear ADCSRA register
ADCSRB = 0; // clear ADCSRB register
ADMUX |= (0 & 0x07); // set A0 analog input pin
ADMUX |= (1 << REFS0); // set reference voltage
ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register
// sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
// for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 ADC clocks
//ADCSRA |= (1 << ADPS2) | (1 << ADPS0); // 32 prescaler for 38.5 KHz
ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
//ADCSRA |= (1 << ADPS1) | (1 << ADPS0); // 8 prescaler for 153.8 KHz
ADCSRA |= (1 << ADATE); // enable auto trigger
ADCSRA |= (1 << ADIE); // enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); // enable ADC
ADCSRA |= (1 << ADSC); // start ADC measurements
}
ISR(ADC_vect) { // store 8 bit value from input
byte inVal = ADCH;
if (x==0)
{
t0 = micros();
}
if (x>=NUMSAMPLES)
{
return;
}
buf[x] = inVal;
x++;
}
void loop()
{
if (x==NUMSAMPLES)
{
// send 255 to mark the beginning of buffer
Serial.write(255);
// send the length of the buffer
Serial.write((byte) (NUMSAMPLES & 0xFF));
Serial.write((byte) ((NUMSAMPLES >> 8) & 0xFF));
// send elapsed time
t = micros()-t0;
Serial.write((byte) (t & 0xFF));
Serial.write((byte) ((t >> 8) & 0xFF));
Serial.write((byte) ((t >> 16) & 0xFF));
Serial.write((byte) ((t >> 24) & 0xFF));
for (int i=0; i<NUMSAMPLES; i++)
{
// do not send 255 because is used to mark the start of the buffer
Serial.write(min(buf[i], 254));
}
x=0;
}
}
And the error is
OScope:45:5: error: expected constructor, destructor, or type conversion before '(' token
ISR(ADC_vect) { // store 8 bit value from input
^
C:\Users\tarik\Desktop\speedUp\OScope\OScope.ino: In function 'void setup()':
OScope:27:3: error: 'ADCSRA' was not declared in this scope
ADCSRA = 0; // clear ADCSRA register
^
OScope:28:3: error: 'ADCSRB' was not declared in this scope
ADCSRB = 0; // clear ADCSRB register
^
OScope:29:3: error: 'ADMUX' was not declared in this scope
ADMUX |= (0 & 0x07); // set A0 analog input pin
^
OScope:30:18: error: 'REFS0' was not declared in this scope
ADMUX |= (1 << REFS0); // set reference voltage
^
OScope:31:18: error: 'ADLAR' was not declared in this scope
ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register
^
OScope:36:19: error: 'ADPS2' was not declared in this scope
ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
^
OScope:39:19: error: 'ADATE' was not declared in this scope
ADCSRA |= (1 << ADATE); // enable auto trigger
^
OScope:40:19: error: 'ADIE' was not declared in this scope
ADCSRA |= (1 << ADIE); // enable interrupts when measurement complete
^
OScope:41:19: error: 'ADEN' was not declared in this scope
ADCSRA |= (1 << ADEN); // enable ADC
^
OScope:42:19: error: 'ADSC' was not declared in this scope
ADCSRA |= (1 << ADSC); // start ADC measurements
^
C:\Users\tarik\Desktop\speedUp\OScope\OScope.ino: At global scope:
OScope:45:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(ADC_vect) { // store 8 bit value from input
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
Baksuz:
This is code, I just copy it form net
You might want to go back to where you copied it from and follow the instructions on how to compile/use it.
It compiles without error for me.
Arduino 1.8.7
I tried three different AVR processors:
Arduino/Genuino UNO
Arduino/Genuino Micro
Arduino/Genuino Mega 2560
What AVR board did you select in Tools->Boards?
Baksuz:
This is whole code my bad for sloppy question.This is code, I just copy it form net
/*
OScope
Oscilloscope based on arduino and Processing.
*/
#include <avr/interrupt.h>
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#define NUMSAMPLES 1024
#define INPUTPIN A0
byte buf[NUMSAMPLES];
int x=0;
unsigned long t, t0;
void setup()
{
// initialize the serial port to 230400 baud, if you have problems lower it to 115200
Serial.begin(230400);
ADCSRA = 0; // clear ADCSRA register
ADCSRB = 0; // clear ADCSRB register
ADMUX |= (0 & 0x07); // set A0 analog input pin
ADMUX |= (1 << REFS0); // set reference voltage
ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register
// sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
// for Arduino Uno ADC clock is 16 MHz and a conversion takes 13 ADC clocks
//ADCSRA |= (1 << ADPS2) | (1 << ADPS0); // 32 prescaler for 38.5 KHz
ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
//ADCSRA |= (1 << ADPS1) | (1 << ADPS0); // 8 prescaler for 153.8 KHz
ADCSRA |= (1 << ADATE); // enable auto trigger
ADCSRA |= (1 << ADIE); // enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); // enable ADC
ADCSRA |= (1 << ADSC); // start ADC measurements
}
ISR(ADC_vect) { // store 8 bit value from input
byte inVal = ADCH;
if (x==0)
{
t0 = micros();
}
if (x>=NUMSAMPLES)
{
return;
}
buf[x] = inVal;
x++;
}
void loop()
{
if (x==NUMSAMPLES)
{
// send 255 to mark the beginning of buffer
Serial.write(255);
// send the length of the buffer
Serial.write((byte) (NUMSAMPLES & 0xFF));
Serial.write((byte) ((NUMSAMPLES >> 8) & 0xFF));
// send elapsed time
t = micros()-t0;
Serial.write((byte) (t & 0xFF));
Serial.write((byte) ((t >> 8) & 0xFF));
Serial.write((byte) ((t >> 16) & 0xFF));
Serial.write((byte) ((t >> 24) & 0xFF));
for (int i=0; i<NUMSAMPLES; i++)
{
// do not send 255 because is used to mark the start of the buffer
Serial.write(min(buf[i], 254));
}
x=0;
}
}
And the error is
OScope:45:5: error: expected constructor, destructor, or type conversion before '(' token
ISR(ADC_vect) { // store 8 bit value from input
^
C:\Users\tarik\Desktop\speedUp\OScope\OScope.ino: In function 'void setup()':
OScope:27:3: error: 'ADCSRA' was not declared in this scope
ADCSRA = 0; // clear ADCSRA register
^
OScope:28:3: error: 'ADCSRB' was not declared in this scope
ADCSRB = 0; // clear ADCSRB register
^
OScope:29:3: error: 'ADMUX' was not declared in this scope
ADMUX |= (0 & 0x07); // set A0 analog input pin
^
OScope:30:18: error: 'REFS0' was not declared in this scope
ADMUX |= (1 << REFS0); // set reference voltage
^
OScope:31:18: error: 'ADLAR' was not declared in this scope
ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register
^
OScope:36:19: error: 'ADPS2' was not declared in this scope
ADCSRA |= (1 << ADPS2); // 16 prescaler for 76.9 KHz
^
OScope:39:19: error: 'ADATE' was not declared in this scope
ADCSRA |= (1 << ADATE); // enable auto trigger
^
OScope:40:19: error: 'ADIE' was not declared in this scope
ADCSRA |= (1 << ADIE); // enable interrupts when measurement complete
^
OScope:41:19: error: 'ADEN' was not declared in this scope
ADCSRA |= (1 << ADEN); // enable ADC
^
OScope:42:19: error: 'ADSC' was not declared in this scope
ADCSRA |= (1 << ADSC); // start ADC measurements
^
C:\Users\tarik\Desktop\speedUp\OScope\OScope.ino: At global scope:
OScope:45:4: error: expected constructor, destructor, or type conversion before '(' token
ISR(ADC_vect) { // store 8 bit value from input
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
Moderator edit: <mark>```</mark> <mark>[code]</mark> <mark>```</mark> <mark>```</mark> <mark>[/code]</mark> <mark>```</mark> tags added.
What board do you have selected? There's a lot more errors in there than just the top one, and they absolutely should not be happening if you have a proper board selected.