Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rewrite the following Arduino code using C code and registers. You may only use Arduino code for the serial and delay functions. #define LED_PIN 13

Rewrite the following Arduino code using C code and registers. You may only use Arduino code for the serial and delay functions.

#define LED_PIN 13

char inChar;

boolean isFreshInChar;

void setup() {

pinMode(LED_PIN , OUTPUT);

digitalWrite(LED_PIN , LOW);

// Set serial monitor console termination for 'No line ending'

Serial.begin(9600);

Serial.println("Lab 1: hello arduino v0.3 ");

delay(5000);

}

void loop() {

isFreshInChar = false;

if (Serial.available()) {

inChar = Serial.read();

Serial.print("Serial input detected: ");

Serial.println(inChar);

isFreshInChar = true;

}

if (inChar == 'n') digitalWrite(LED_PIN , HIGH); // oN

if (inChar == 'f') digitalWrite(LED_PIN , LOW); // oFf

if (inChar == 'b') { // blink with 25% duty cycle

digitalWrite(LED_PIN , HIGH);

delay(250);

digitalWrite(LED_PIN , LOW);

delay(750);

}

// Discover 't' persistence bug by observing high rate LED blink

if (inChar == 't') { // toggle

digitalWrite(LED_PIN , !digitalRead(LED_PIN ));

}

// Add state change detection to get proper toggle action.

if (inChar == 'T') { // toggle

if (isFreshInChar) digitalWrite(LED_PIN , !digitalRead(LED_PIN ));

}

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

How does or how might the key public affect your organization?

Answered: 1 week ago