Pages: [1]   Go Down
Author Topic: Practice Lesson - Do/While  (Read 418 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Write software to print square root of first 100 natural numbers on the serial console using a Do ... while structure.
Each time a number is printed, the LED connected to pin 13 should blink.
Blinking rate should be 2Hz.
Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 64
Posts: 2100
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Write software to print square root of first 100 natural numbers on the serial console using a Do ... while structure.
Will I get in trouble for using for loops

Quote
Each time a number is printed, the LED connected to pin 13 should blink.
No the serial Tx lights will blink, unless this is what your teacher wants you to do.

Quote
Blinking rate should be 2Hz
My arduino is smarter than that, I get 2Hz using a calculator.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

no problem with loops.

Using an Arduino Uno, which has an LED on pin 13. It should be told to blink whenever it prints the root to the serial display.

Not a homework or exam or anything - just one of a list of a few scenarios that we can try on our own - but he has no 'answer key.'


* b4dbad20cc8d048ebc97a135cf8f3425.media.500x385.jpg (40.41 KB, 500x385 - viewed 4 times.)
« Last Edit: February 07, 2012, 02:27:46 am by l2program » Logged

North Queensland, Australia
Online Online
Edison Member
*
Karma: 64
Posts: 2100
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That LED will flash when the pin attached to it is turned on (13 set to output and HIGH).
You could use a <500 ms delay in between steps to slow things down.
Before you print out, turn the LED on
then after sending data turn LED off, or even use a delay to keep it on.

Read the 'blink without delay' example to see a smarter way to control the program flow.

Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Not a homework or exam or anything - just one of a list of a few scenarios that we can try on our own - but he has no 'answer key.'
Still sounds like school work. You won't learn anything if we do you school work for you.

There are several parts to the assignment.
Quote
Write software to print square root of first 100 natural numbers on the serial console
You need to be able to print to the serial console. You need to be able to compute the square root of a value. You need to understand int vs. float, and choose the appropriate storage type. You need to determine how to perform an action a specific number of times. You need to decide whether a value is a natural number or not (whatever that means).

You will learn nothing if we do any of this for you.

If you try something, and it does not work, and you explain what you expected and what you got, we'll be happy to point out what is wrong, and suggest how you might fix it.
Logged

Pages: [1]   Go Up
Jump to: