Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a problem and write an AVR C program to create 5 inputs with correspondin

ID: 3702065 • Letter: D

Question

Design a problem and write an AVR C program to create 5 inputs with corresponding 5 different outputs. The instruction is listed to follow. Instruction:

?AVR C code must be used

?Any conditional statement must be used (e.g.IF statement or CASE statement)

?At least one time, you must use the time delay for your output

?Bit-wise logic and shift operator

1. You can choose any format of 5 reading from your input PORT. For example, you can use the joystick on the butterfly board to get 5 inputs or you can choose 3 switches to create 5 inputs.

2. You can choose any output method. For example, you can use letters or Display the letters on 7 segment display . Or,you can use ASCII number corresponding letters shown in the table and display on LED in the binary or sequential number using the 7_segment display with delay. (e.g. The hex value corresponding to ASCII letter ‘A’ can be shown in 7 segments as numbers.)

< Example Inputs and Outputs

Input Output

000 A

001 B

010 C

011 D

100 E

flow chart

Explanation / Answer

Answer :

#include <avr/io.h>

#define F_CPU 4000000UL

#include <util/delay.h>

int main()

{

//configure B as input

//The last five bits of B can be taken as five different inputs

DDRB = 0x00;

//configure port C as output

DDRC = 0xFF;

//extract the last bit

int a=PINB &0b00000001

//if last bit is 1

if(a==1)

//On the last LED

PORTC = 0xFE;

//wait for 1 sec

_delay_ms(1000);

//extract the second last bit

int a=PINB &0b00000010

//if second last bit is 1

if(a==1)

//on all the leds

PORTC = 0x00;

//wait for 1 sec

_delay_ms(1000);

//extract the third last bit

int a=PINB &0b00000100

//if thirdd last bit is 1

if(a==1)

//on all the led from third

PORTC = 0xF8;

//wait for 1 sec

_delay_ms(1000);

//extract the fourth last bit

int a=PINB &0b00001000

//if fourth last bit is 1

if(a==1)

//display even position Leds on

PORTC = 0xAA;

//wait for 1 sec

_delay_ms(1000);

//extract the fifth input bit

int a=PINB &0b00010000

//if bit is 1

if(a==1)

//perform the shift of the input

PORTC = PINC<<2;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote