|
|
![]() |
#1 | |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $-855043
|
Quote:
|
|
Posts: 7,765
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#2 | |
King Sandbagger
Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $-930000
|
Quote:
Disclaimer, I didn't stay at a Holiday Inn Express last night but I have taught object oriented programming at a state university for almost 10 years. |
|
Posts: 3,959
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() ![]() |
![]() |
#3 | |
Veteran
Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $3876254
|
Quote:
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. |
|
Posts: 1,223
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() ![]() |
![]() |
#4 | |
King Sandbagger
Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $-930000
|
Quote:
|
|
Posts: 3,959
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#5 | |
www.nfl-forecast.com
Join Date: Sep 2000
Casino cash: $-478231
|
Quote:
I have been programming on a regular basis for more than 40 years. I built from scratch a website that contains more than 30,000 lines of code. Even with my experience, when I started fiddling with arduino boards (which sounds like what your son is working with) a few years ago out of curiosity, I would have broken the problem your son is working on now into these tiny mini projects. Literally some of the first things I did with the arduino were to turn on an led, turn on an led with a switch, turn on an led for random periods of time, etc. My goal project was to time how long it took for weighing lever to tip using an accelerometer, and combine that information from a level sensor to calculate the velocity of water flow in a channel. This had nothing to do with leds being on or off. But because I was working in a new ecosystem, I started with the most basic of baby steps. When I built my goal project, it involved maybe half a dozen sub projects along the way. When I fully understood each sub project, composing them into the final project was fairly easy because of the familiarity I had built up working on the sub projects. |
|
Posts: 46,032
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ![]() ![]() |
![]() |
#6 |
Veteran
Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $3876254
|
Lots of good advice here. I think cdcox and I may have a lot in common. I too have been programming for a long time. Started at 14 yrs old on an Atari 800. That was a few years ago!
Ok, so I dug out my last ESP32 project. If you are using the Arduino IDE, which I would assume you are, you can print variable values to the console by using "Serial.println()". So for instance, if you are trying to see what the actual value of your pressure sensor is, you could do something like this: Code:
pressureValue = analogRead(A0); Serial.println(pressureValue); |
Posts: 1,223
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#7 |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $-855043
|
Appreciate the help guys , not sure if he figured it out i went to bed but will let you know
|
Posts: 7,765
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#8 | |
MVP
Join Date: Aug 2005
Casino cash: $3519212
|
Quote:
Also (and I've never worked with this Arduino stuff), since he already is setting up the serial port for comms, will Serial.print work as someone suggested? Or will that output over the current serial port link? |
|
Posts: 14,737
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#9 | |
Veteran
Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $3876254
|
Quote:
When doing Arduino programming and debugging, the serial line is how you write and read data from the device as it is operating. In essence, your IDE compiles down the C++ sketch file into a binary, uploads that over the serial line to the Arduino device, and then resets it. The reset makes it execute your code. The serial connection remains open, and any messages from the Arduino are sent across. |
|
Posts: 1,223
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
#10 | |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $-855043
|
Quote:
Normally I would spend the next few months and hundreds of hours learning some coding to be able to help him out but I have absolutely no interest . |
|
Posts: 7,765
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() ![]() |
|
|