Go Down

Topic: Practice Lesson - Do/While (Read 480 times) previous topic - next topic

l2program

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.

pYro_65

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.

l2program

#2
Feb 07, 2012, 08:19 am Last Edit: Feb 07, 2012, 08:27 am by l2program Reason: 1
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.'

pYro_65

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.


PaulS

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.

Go Up