Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with this question. Here's the code i have so for but it doesn't work : #define F_CPU 16000000UL #include #include #include #include #define

Please help with this question. Here's the code i have so for but it doesn't work :

#define F_CPU 16000000UL

#include

#include

#include

#include

#define BAUD 9600

#define MYUBRR ((F_CPU)/(BAUD*16UL)-1)

#include

void delay(int y) {

for(int m =0; m

{

_delay_us(1);

}

}

float freq(float x)

{

double expo1 = pow(2.0,1.0/12.0);

double expo2 = pow(expo1,x);

double wave = 1.0/(440.0 * expo2);

return wave * 100000;

}

void scan_keypad(void)

{

PORTD |= ((1

PORTD &= ~(1

PORTB |= 0b00011110;

if(!(PINB & 1

int w = freq(0);

PORTC|=(1

delay(w);

PORTC &= ~(1

delay(w);

}

if(!(PINB & 1

PORTC|=(1

int w = freq(1);

delay(w);

PORTC &= ~(1

delay(w);

//return 1;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(2);

delay(w);

PORTC &= ~(1

delay(w);

//return 2;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(3);

delay(w);

PORTC &= ~(1

delay(w);

//return 3;

}

PORTD |= ((1

PORTD &= ~(1

PORTB |= 0b00011110;

if(!(PINB & 1

PORTC|=(1

int w = freq(4);

delay(w);

PORTC &= ~(1

delay(w);

//return 4;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(5);

delay(w);

PORTC &= ~(1

delay(w);

//return 5;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(6);

delay(w);

PORTC &= ~(1

delay(w);

//return 6;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(7);

delay(w);

PORTC &= ~(1

delay(w);

//return 7;

}

PORTD |= ((1

PORTD &= ~(1

PORTB |= 0b00011110;

if(!(PINB & 1

PORTC|=(1

int w = freq(8);

delay(w);

PORTC &= ~(1

delay(w);

//return 8;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(9);

delay(w);

PORTC &= ~(1

delay(w);

//return 9;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(10);

delay(w);

PORTC &= ~(1

delay(w);

//return 10;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(11);

delay(w);

PORTC &= ~(1

delay(w);

//return 11;

}

PORTD |= ((1

PORTD &= ~(1

PORTB |= 0b00011110;

if(!(PINB & 1

PORTC|=(1

int w = freq(12);

delay(w);

PORTC &= ~(1

delay(w);

//return 12;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(13);

delay(w);

PORTC &= ~(1

delay(w);

//return 13;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(14);

delay(w);

PORTC &= ~(1

delay(w);

//return 14;

}

if(!(PINB & 1

PORTC|=(1

int w = freq(15);

delay(w);

PORTC &= ~(1

delay(w);

//return 15;

}

//return 0;

}

void USART_Init ()

{

UBRR0H = (MYUBRR>>8); // shift the register right by 8 bits

UBRR0L = MYUBRR; // set baud rate

UCSR0B |= (1

UCSR0C |= (3

}

void USART_Transmit(unsigned char data)

{

while (!(UCSR0A & (1

UDR0 = data;

}

int main(void)

{

DDRD |= ((1

DDRB &= ~((1

DDRC |= (1

while(1){

scan_keypad();

}

}

image text in transcribed

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

=+phenomenon? How did this affect your life at that time?

Answered: 1 week ago

Question

How does this scenario illustrate the process of mainstreaming?

Answered: 1 week ago