Programming ADC for LM35 by Atmel Visual Studio

Dear Guys

:frowning: :frowning: :frowning: :frowning: :frowning:

Can I help me , please . I try to program for Atmel Visual Studio
I dont get to show the temperature for USART.

Follow this program

/*

  • Modulo_3_Termometro.cpp
  • Created: 06/06/2015 10:11:25
  • Author: Marcos
    */
    volatile int valor=0;
    double temp;
    #define F_CPU 160000000L
    #define USART_BAUDRATE 9600
    #define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
    #include <avr/interrupt.h>
    #include <stdio.h>
    #include <avr/io.h>
    #include <util/delay.h>

void USART_Init( unsigned int ubrr)
{
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
UCSR0C = (1<<USBS0)|(3<<UCSZ00);
}
void USART_Transmit(unsigned char data)
{
while(!(UCSR0A &(1<<UDRE0)))
UDR0 = data;

}

ISR (ADC_vect)
{
volatile uint8_t valor=0;
valor = ADCH;
temp = valor * 0.1075268817204301;
USART_Transmit(temp);
ADCSRA |= (1<<ADSC);
}

int main(void)
{
USART_Init(BAUD_PRESCALE);

ADMUX|=(1<<REFS0)||(1<<REFS1)||(1<<ADLAR)||(0<<MUX3)||(0<<MUX2)||(0<<MUX1)||(0<<MUX0);

ADCSRA|=(1<<ADEN)||(1<<ADSC)||(1<<ADIF)||(1<<ADATE)||(1<<ADIF)||(1<<ADIE)||(1<<ADPS0)||(1<<ADPS1)||(1<<ADPS2);

ADCSRB &=(0<<ADTS2)||(0<<ADTS1)||(0<<ADTS2);

sei();

while(1)
{
ISR(ADC_vect)
_delay_ms(1000);
}
}

I have some error during compilation

Error 1 : expected unqualified-id before string constant
Error 2 : expected initializer before '_delay_ms'

Hi,
Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom... :slight_smile:

Post all compiler errors verbatim using copy and paste...