Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Follow the instruction and read the comment line, and write C programming Language - Embedded Systems Class #include #include #include lcd.h int main(void) { //

Follow the instruction and read the comment line, and write C programming Language - Embedded Systems Class

#include #include

#include "lcd.h"

int main(void) {

// Setup DDR and PORT bits for the 2 input buttons // as necessary

// Initialize the LCD // Use a state machine approach to organize your code // - Declare and initialize a variable to // track what state you are in while (1) { // Loop forever

// Use an outer if statement to select what state you are in // Then inside each 'if' or 'else' block, perform the desired // output operations and then sample the inputs to update // the state for the next iteration // Delay before we go to the next iteration of the loop }

return 0; /* never reached */ }

/* lcd.c - Routines for sending data and commands to the LCD shield */

#include #include

#include "lcd.h" // Declarations of the LCD functions

/* This function not declared in lcd.h since should only be used by the routines in this file. */ void lcd_writenibble(unsigned char);

/* Define a couple of masks for the bits in Port B and Port D */ #define DATA_BITS ((1 << PD7)|(1 << PD6)|(1 << PD5)|(1 << PD4)) #define CTRL_BITS ((1 << PB1)|(1 << PB0))

/* lcd_init - Do various things to initialize the LCD display */ void lcd_init(void) { /* ??? */ // Set the DDR register bits for ports B and D // Take care not to affect any unnecessary bits

_delay_ms(15); // Delay at least 15ms

/* ??? */ // Use lcd_writenibble to send 0b0011 _delay_ms(5); // Delay at least 4msec

/* ??? */ // Use lcd_writenibble to send 0b0011 _delay_us(120); // Delay at least 100usec

/* ??? */ // Use lcd_writenibble to send 0b0011, no delay needed

/* ??? */ // Use lcd_writenibble to send 0b0010 _delay_ms(2); // Delay at least 2ms lcd_writecommand(0x28); // Function Set: 4-bit interface, 2 lines

lcd_writecommand(0x0f); // Display and cursor on }

/* lcd_moveto - Move the cursor to the row and column given by the arguments. Row is 0 or 1, column is 0 - 15. */ void lcd_moveto(unsigned char row, unsigned char col) { unsigned char pos; if(row == 0) { pos = 0x80 + col; // 1st row locations start at 0x80 } else { pos = 0xc0 + col; // 2nd row locations start at 0xc0 } lcd_writecommand(pos); // Send command }

/* lcd_stringout - Print the contents of the character string "str" at the current cursor position. */ void lcd_stringout(char *str) { int i = 0; while (str[i] != '

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

Step: 3

blur-text-image

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

2. Clearly identify time constraints.

Answered: 1 week ago

Question

explain the impact of heuristics in query processing ( 5-6marks)

Answered: 1 week ago