Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Arduino Uno Code: int redOn = HIGH; int greenOn = HIGH; void setup() { pinMode(2, OUTPUT); pinMode(4, OUTPUT); digitalWrite(2, redOn); digitalWrite(4, greenOn); Serial.begin(9600); } void

Arduino Uno Code:

int redOn = HIGH; int greenOn = HIGH; void setup() { pinMode(2, OUTPUT); pinMode(4, OUTPUT); digitalWrite(2, redOn); digitalWrite(4, greenOn); Serial.begin(9600); } void loop() { delay(10); // Delay a little bit to improve simulation performance digitalWrite(2, redOn); digitalWrite(4, greenOn);

if(Serial.available()){ char c = Serial.read(); if (c == 'r'){ if (redOn == HIGH){ redOn = LOW; Serial.println("Red LED Off"); } else{ redOn = HIGH; Serial.println("Red LED On"); } } if (c == 'g'){ if (greenOn == HIGH){ greenOn = LOW; Serial.println("Green LED Off"); } else{ greenOn = HIGH;

Serial.println("Green LED On"); } } } }

Question:

Based on the code provided, add the following three functions to the circuit:

  1. If a is typed into the serial monitor, both LEDs turn on and the message All LEDs On is displayed.
  2. If o is typed into the serial monitor, both LEDs turn off and the message All LEDs Off is displayed.
  3. If a character other than r, g, a or o is typed into the serial monitor, the message Unknown Command is displayed.

Please provide Arduino code! Thanks!

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions