Make Yourself a Speaking ATMEGA128
by arick in Circuits > Microcontrollers
4167 Views, 20 Favorites, 0 Comments
Make Yourself a Speaking ATMEGA128
Guys,
In previous weekend, I made myself a speaking ATMEGA128.
I used ATMEGA128 and LM386 as an amplifier,
Let's get started
In previous weekend, I made myself a speaking ATMEGA128.
I used ATMEGA128 and LM386 as an amplifier,
Let's get started
The Part I Need for This Project
These parts are needed for this project :
1. LM386
2.ATMEGA128
3.USBISP
4.AVRStudio
5. Small speaker
6. LCD 16x2
1. LM386
2.ATMEGA128
3.USBISP
4.AVRStudio
5. Small speaker
6. LCD 16x2
Assemble the Project
Here's the connection I used for this project :
I connected PB5 as an input for LM386
and for LCD :
#define lcd_data_pin PORTA
#define en PORT_D.b2
#define rs PORT_D.b3
#define rw PORT_D.b4
I connected PB5 as an input for LM386
and for LCD :
#define lcd_data_pin PORTA
#define en PORT_D.b2
#define rs PORT_D.b3
#define rw PORT_D.b4
The Code
I used PWM and timer for this project
void pwm_init(void)
{
/* use OC1A pin as output */
DDRB = _BV(PB5);
/*
* clear OC1A on compare match
* set OC1A at BOTTOM, non-inverting mode
* Fast PWM, 8bit
*/
TCCR1A = _BV(COM1A1) | _BV(WGM10);
/*
* Fast PWM, 8bit
* Prescaler: clk/1 = 8MHz
* PWM frequency = 8MHz / (255 + 1) = 31.25kHz
*/
TCCR1B = _BV(WGM12) | _BV(CS10);
/* set initial duty cycle to zero */
OCR1A = 0;
/* Setup Timer0 */
TCCR0|=(1<<CS00);
TCNT0=0;
TIMSK|=(1<<TOIE0);
sample_count = 4;
sei(); //Enable interrupts
}
void pwm_init(void)
{
/* use OC1A pin as output */
DDRB = _BV(PB5);
/*
* clear OC1A on compare match
* set OC1A at BOTTOM, non-inverting mode
* Fast PWM, 8bit
*/
TCCR1A = _BV(COM1A1) | _BV(WGM10);
/*
* Fast PWM, 8bit
* Prescaler: clk/1 = 8MHz
* PWM frequency = 8MHz / (255 + 1) = 31.25kHz
*/
TCCR1B = _BV(WGM12) | _BV(CS10);
/* set initial duty cycle to zero */
OCR1A = 0;
/* Setup Timer0 */
TCCR0|=(1<<CS00);
TCNT0=0;
TIMSK|=(1<<TOIE0);
sample_count = 4;
sei(); //Enable interrupts
}
Test and Enjoy Yourself a Speaking ATMEGA128
Test and enjoy yourself a speaking ATMEGA128
See and hear the video :
Thanks for reading and enjoy the project ;)
See and hear the video :
Thanks for reading and enjoy the project ;)