Thread: Computers Nerd homework
View Single Post
Old 10-14-2021, 07:29 AM   #35
phisherman phisherman is online now
King Sandbagger
 

Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $1645484
Quote:
Originally Posted by stanleychief View Post
Very true for the real world. For Arduino sketches though, it's pretty simplified. OO design here would likely be overkill. For a sketch file, you essentially have two methods that execute: setup and loop.

In setup, you initialize your variables, pins, etc. In loop, you put in the code that will repeatedly execute in a loop.

Considering the stated objectives, I'd solve the problem in the loop code like so:

* Read the pressure sensor value and convert that to a decimal value between 0 and 1.
* Generate random values for red, green and blue LEDs and store those values into three variables.
* Multiply each of those three variables by the converted pressure sensor value.
* Write the three values to the RGB LED output pins.
Well explained with a great algorithm added! Rep!
Posts: 3,808
phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.phisherman wants to die in a aids tree fire.
    Reply With Quote