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

An ATMega328P microcontroller is clocked at 16 MHz. Write a complete C program t

ID: 2084902 • Letter: A

Question

An ATMega328P microcontroller is clocked at 16 MHz. Write a complete C program that will mimic a police car chase LED sequence using different peripherals on your microcontroller. This programming question is broken down into three sub-questions. So read the question carefully. You will have to build a circuit on the breadboard with different peripherals as mentioned in each sub-question. Hardwa Required Arduino board Two RED LEDs and Two BLUE LEDs One push-button (from your 106/107 kit) One potentiometer (from your 106/107 kit) A breadboard (from your 106/107 kit) Four 2200 resistors (each to be connected between Arduino pin and the anode of LED) One push-button (from your 106 107 kit) One IKS2 resistor (to be connected between 5V and Arduino pin) Final Schematic OO(UNO) NOTE: You will have to build the circuit as required by each sub-question.

Explanation / Answer

Arduino Code:

=====================

void setup() {
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
}

void loop() {
int i=0,chase=0;
chase=digitalRead(3);
if(!chase){
for(i=0;i<=30;i++){
digitalWrite(4,i%2);
digitalWrite(5,i%2);
delay(200);
digitalWrite(6,(i+1)%2);
digitalWrite(7,(i+1)%2);
delay(200);
}
}
}

=========================

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