decapitary
Banned
i need a c file to program my micro for A2D. I have 1 analog input and just ONE serial output please help me Fast
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hi,
There are example codes in the avr datasheet and a huge ammount of threads in the forum and the internet.
If you need something special, then you need to specify it.
Asking for fast help, but giving no details is resulting in no answers..
Klaus
#define F_CPU 16000000UL
#include <util/delay.h>
#include <avr/io.h>
int main(void)
{
DDRA=0;
//Declaring Port A as input
DDRB=255;
//Declaring port B as output
ADCSRA|=(1<<ADEN)|(1<<ADPS2) |(1<<ADPS1) |(1<<ADPS0);
// Enabled ADC and set prescaler division factor as 128
ADMUX|=(0<<REFS1)|(1<<REFS0)|(0<<MUX4)|(0<<MUX3)|(0<<MUX2)|(0<<MUX1)|(0<<MUX0)|(1<<ADLAR);
/*Vref is same as Vcc, Input constantly at Pin 0 of port A and Setting ADLAR to 1 left shifts the bits for an 8-bit precision*/
while(1)
{
ADCSRA|=(1<<ADSC);
//Start ADC
while((ADCSRA& (1<<6))!=0);
/*Do nothing till the conversion is over. Here, the condition that ADSC is cleared after conversion has been used. You can also use ADIF*/
PORTB = ADCH;
/*The ADC value stored in ADCH has been sent to PORT B as output.*/
_delay_ms(100);
};
}
Asking for fast help, but giving no details is resulting in no answers..
google for "atmega uart optocoupler"Do You Have any Idea how should I connect AVR and optocoupler Pins?
look into datasheetShould I connect a RC circuit for RESET pin?
We do not know:how i should connect my Analog into Atmega8 pin?
of what device?Which pins need +5 and which for GND?
The ECG signal can be connected to AVR-ADC after being amplified to 5V. I presume you have a suitable preamplifier.
Connecting "UART to optocoupler then to USB" is less clear. You need an USB interface chip like FT232 to connect UART to USB, maybe with optical isolation by an optocoupler.
people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/cwm55/cwm55_mj294/