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

C Programming Only Requirement : You must demo your program on a dragon12-Light

ID: 3845923 • Letter: C

Question

C Programming Only

Requirement: You must demo your program on a dragon12-Light board.

Goal: To become familiar with using the analog-to-digital converter units on the board, using Dragon12-Light boards, as well to improve your programming skills.

Project: Write a C program to do the following:

write this program to see how the light sensor inputs are converted to binary data on the controller board; please understand this program completely.

use the polling method

Modify this program to use interrupt method.

For an example of using interrupt method for ATD, please study Program 13-2C on page 453 of the textbook.

Explanation / Answer

#include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRE = DDRE | 0b00000100; // PE2 as output for (;;) { PORTE = PORTE | 0b00000100; //make PE2=1 to turn on relay MSDelay(500); //change the delay size to see what happens PORTE = PORTE & 0b11111011; //Make PE2=0 to turn off relay MSDelay(500); //change delay size.... } } void MSDelay(unsigned int itime) //msec delay { unsigned int i; unsigned int j; for(i=0;i