My project is to perform or visualize a input signal from frequency generator on a PC screen as i am in middleway stuck in correcting arduino code
My concepts on project is
take an analog signal, start sampling , raise an interrupt in interrupt u assign volatile memory( information i have attached to this post. )
So, I am stuck in interrupt function as I am considering array of data to transfer from serial port on to Pc screen so I want your corrections on my code . As I have less knowledge abt microcontrollers .
So, what are the changes that can be made as i am succesful in activating ADC (ATmega328p) but I am finding it hard to declare an array function for volatile memory I store as I have least knowledge of how to use an array function.
But my concept is take a sampled data from adc and store it in array of 16 bits and than declare an array to the volatile memory than serial transfer from memory to PC screen.
In this I am getting an error as expected unqualified-id before string constant
So please help me in improvising the code.
Thank you well in advance.
Code is as follows:

// Testing interrupt-based analog reading
// ATMega328p

// Note, many macro values are defined in <avr/io.h> and
// <avr/interrupts.h>, which are included automatically by
// the Arduino interface

// High when a value is ready to be read
volatile int readFlag;

// Value to store analog result
volatile int analogVal;
//const int analogInPin = A0;
unsigned int i ;

// Initialization
void setup(){

// clear ADLAR in ADMUX (0x7C) to right-adjust the result
// ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits)
ADMUX &= B11011111;

// Set REFS1…0 in ADMUX (0x7C) to change reference voltage to the
// proper source (01)
ADMUX |= B01000000;

// Clear MUX3…0 in ADMUX (0x7C) in preparation for setting the analog
// input
ADMUX &= B11110000;

// Set MUX3…0 in ADMUX (0x7C) to read from AD8 (Internal temp)
// Do not set above 15! You will overrun other parts of ADMUX. A full
// list of possible inputs is available in Table 24-4 of the ATMega328
// datasheet
ADMUX |= 8;
// ADMUX |= B00001000; // Binary equivalent

// Set ADEN in ADCSRA (0x7A) to enable the ADC.
// Note, this instruction takes 12 ADC clocks to execute
ADCSRA |= B10000000;

// Set ADATE in ADCSRA (0x7A) to enable auto-triggering.
ADCSRA |= B00100000;

// Clear ADTS2…0 in ADCSRB (0x7B) to set trigger mode to free running.
// This means that as soon as an ADC has finished, the next will be
// immediately started.
ADCSRB &= B11111000;

// Set the Prescaler to 128 (16000KHz/128 = 125KHz)
// Above 200KHz 10-bit results are not reliable.
ADCSRA |= B00000111;

// Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt.
// Without this, the internal interrupt will not trigger.
ADCSRA |= B00001000;

// Enable global interrupts
// AVR macro included in <avr/interrupts.h>, which the Arduino IDE
// supplies by default.

// Kick off the first ADC
readFlag = 0;
// Set ADSC in ADCSRA (0x7A) to start the ADC conversion
ADCSRA |=B01000000;

// Processor loop
void loop(){

// Check to see if the value has been updated
if (readFlag == 1){

// Perform whatever updating needed??? so I require a code for serial transmission so suggest a proper body


readFlag = 0;

// Whatever else you would normally have running in loop().


// Interrupt service routine for the ADC completion
void ISR (ADC_vect){

// Done reading
readFlag = 1;

// Must read low first
// analogVal = ADCL | (ADCH << 8);

analogVal = ADCL | (ADCH << 8);
if (i<16) // concept of mine is to use as a circular buffer an array as a buffer for 16bits

// Not needed because free-running mode is enabled.
// Set ADSC in ADCSRA (0x7A) to start another ADC conversion
// ADCSRA |= B01000000;

Maybe you need to read this first.

Are you in the same class with this guy ?


What a great idea ! I saved it for future use.

i am in middleway stuck in correcting arduino code

I think that's a slight exaggeration. You didn't write that code, did you? It's Glenn Sweeney's work. You found it, and now you're asking us to change it for you to do what you need. At which point, presumably, you'll aim to pass it off as your own work.

Shame on you Did you think we wouldn't see through your ruse ?