QUESTION 1 Complete the part shown in red. Persistent Of Vision #include #includ
ID: 3747070 • Letter: Q
Question
QUESTION 1 Complete the part shown in red. Persistent Of Vision #include #include /***Functions Il function prototype to make all portB pins output ll function prototype that will take one argument (an 8-bit data as input) this data will be displayed on portB int main(void) IwM "Initialization**** ! call your setup function //" Main loop "** while (1) Il call your display function sending 0b00001110 as data Il call your display function sending Ob00011000 as data // call your display function sending Ob10111101 as data ll call your display function sending Ob01110110 as data lI call your display function sending Ob00111100 as data /l call your display function sending 0b00111100 as data ll call your display function sending 0b00111100 as data /I call your display function sending Ob01110110 as data l! call your display function sending 0b10111101 as data /l call your display function sending Ob00011000 as data Il call your display function sending 0b00001110 as data PORTB 0b00000000 _delay_ms(10) Il wnite your set up function that will make all portB pins outpút /I write your display function that will take 8 bits of data and display this Il information on portB with a 2 mS delay. Compile and test your program on Arduino uno board TT T ArialExplanation / Answer
#include <avr/io.h>
#include <util/delay.h>
#define MrLCDsCrib PORTB
#define DataDir_MrLCDsCrib DDRB
#define MrLCDsControl PORTD
#define DataDir_MrLCDsControl DDRD
#define LightSwitch 5
#define ReadWrite 7
#define BiPolarMood 2
void Check_IF_MrLCD_isBusy(void);
void Peek_A_Boo(void);
void Send_A_Command(unsigned char command);
void Send_A_Character(unsigned char character);
void Send_A_String(char *string);
int main(void)
{
DataDir_MrLCDsControl |= 1<<LightSwitch | 1<<ReadWrite | 1<<BiPolarMood;
_delay_ms(15);
Send_A_Command(0x01); //Clear Screen 0x01 = 00000001
_delay_ms(2);
Send_A_Command(0x38);
_delay_us(50);
Send_A_Command(0b00001110);
_delay_us(50);
Send_A_Character(0x4E); //N
Send_A_Character(0x65); //e
Send_A_Character(0x77); //w
Send_A_Character(0x62); //b
Send_A_Character(0x69); //i
Send_A_Character(0x65); //e
Send_A_Character(0x48); //H
Send_A_Character(0x61); //a
Send_A_Character(0x63); //c
Send_A_Character(0x6B); //k
Send_A_Character(0x2E); //.
Send_A_Character(0x63); //c
Send_A_Character(0x6F); //o
Send_A_Character(0x6D); //m
Send_A_String("Patrick");
while(1)
{
}}
void Check_IF_MrLCD_isBusy()
{
DataDir_MrLCDsCrib = 0;
MrLCDsControl |= 1<<ReadWrite;
MrLCDsControl &= ~1<<BiPolarMood;
while (MrLCDsCrib >= 0x80)
{
Peek_A_Boo();
}
DataDir_MrLCDsCrib = 0xFF; //0xFF means 0b11111111}
void Peek_A_Boo()
{
MrLCDsControl |= 1<<LightSwitch;
asm volatile ("nop");
asm volatile ("nop");
MrLCDsControl &= ~1<<LightSwitch;
}
void Send_A_Command(unsigned char command)
{
Check_IF_MrLCD_isBusy();
MrLCDsCrib = command;
MrLCDsControl &= ~ ((1<<ReadWrite)|(1<<BiPolarMood));
Peek_A_Boo();
MrLCDsCrib = 0;
}
void Send_A_Character(unsigned char character)
{
Check_IF_MrLCD_isBusy();
MrLCDsCrib = character;
MrLCDsControl &= ~ (1<<ReadWrite);
MrLCDsControl |= 1<<BiPolarMood;
Peek_A_Boo();
MrLCDsCrib = 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.