Question
Homework 2 - Pattern Display II Learning Objective:Use of global variables, if and for statements. Problem:Write a program that prints following pattern in Serial Monitor
Homework 2
- Pattern Display II
Learning Objective:Use of global variables, if and for statements.
Problem:Write a program that prints following pattern in Serial Monitor repeatedly with a delay of 1 second between each iteration
-
--
---
----
-----
------
-------
--------
---------
----------
---------
--------
-------
------
-----
----
---
--
-
Hints:
Use two global variables to keep track of: count how many hyphens to print on each line, increment or decrement this variable
. In loop() func
tion, use a for loop to print number
of hyphens
equal to count on each line.
Use if statements to increment/decrement count and toggle variable
Troubleshoot:
Nothing prints
initialize Serial Monitor.
Software flowchart:
Write your program according to flowchart g
iven on the next page.
C/C++
count=1 total = 10 inc = true Initialize Serial Monitor i=0 Print a hyphen Ves i count Print new line NO Yes inc es true count = count-1 count = count-1 r es Count sto inc = false Yes inc=true delay for 1 Second count == 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started