Question: Edit the code to perform the following actions Configure P2.4 and P2.5 as digital inputs When testing with hardware, push none, one or both buttons

Edit the code to perform the following actions

Configure P2.4 and P2.5 as digital inputs

When testing with hardware, push none, one or both buttons

Press a key on the keyboard (while none, one or both buttons are pushed)

If no buttons are pushed, print "No buttons pushed"

If one button is pushed, print "One button pushed"

If both buttons are pushed, print "Both puttons pushed"

Repeat steps 2-6

To verify your code, you will want to mount your protoboard on the car and build a test circuit using pushbuttons or slideswitches. To fully test your code, you will need SecureCRT for the print and getchar statements.

Below is the C code file template that needs to be modified.

* Name: Section: Side: Date: Port bits/Digital I/O: (for example: 1.0,1.1) File name: hw4.c Description: Basic template for Homework 4 This program uses two digital inputs */ //----------------------------------------------------------------------------- // Header Files //----------------------------------------------------------------------------- #include // include files. This file is available online #include  //----------------------------------------------------------------------------- // Function Prototypes //----------------------------------------------------------------------------- void Port_Init(void); // digial port initialization void Check_Inputs(void); // output after first character press //----------------------------------------------------------------------------- // Global Variables //----------------------------------------------------------------------------- // // edit sbit commands as appropriate to your assignment //__sbit __at ???? ???? //__sbit __at ???? ???? //*************** void main(void) // { Sys_Init(); // System Initialization putchar(' '); Port_Init(); // port initialization function while(1) { printf("Press a key to check which buttons are pushed "); getchar(); Check_Inputs(); } } //*************** // configure P2MDOUT or P3MDOUT // void Port_Init(void) { //edit this function as appropriate to your assignment } //*************** // edit the arguments to the if/else if statements, as needed // use sbit labels to output digital signals after first character press // void Check_Inputs(void) { if (????) // both buttons pushed { printf("Both buttons pushed "); } else if (????) // one button pushed { printf("Only one button pushed "); } else if (????) // no buttons pushed { printf("No buttons pushed "); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!