Home Discord Chat
Go Back   ChiefsPlanet > Nzoner's Game Room
Register FAQDonate Members List Calendar

Reply
 
Thread Tools Display Modes
Old 10-13-2021, 10:20 PM   #1
Monticore Monticore is online now
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $-855043
Quote:
Originally Posted by cdcox View Post
He shouldn’t try to write the entire code all at once. It can be too hard to hold the whole logic flow in his head all at once, even for a small problem like this. Instead, he should break it down into simpler projects that will contribute to the larger solution.

1. Turn an rgb strip on.
2. Make an rgb strip show random colors.
3. Make an rgb strip turn on only when the touch pad is touched.
4. Make an rgb strip intensity responsive to pressure.
5. Combine 2 and 4. Done.

This process of breaking problems down into smaller manageable parts and then composing the big solution from smaller solutions is a very important skill for engineering or software. As a budding engineer, he should focus on one tiny task in isolation of the others and just keep pounding on it until he gets a breakthrough. Most likely he will find the activity of solving small problems all consuming.

This will be the process he follows his entire career. If he tries to grapple with the big problem all at once, it can get confusing and frustrating very fast. Imagine trying to design a whole commercial airplane all at once. Every engineer breaks complicated problems into smaller, manageable parts and knocks them down one at a time.
he just doesn't know how to combine it i think he can't make it do the rest.
Posts: 7,765
Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.
    Reply With Quote
Old 10-13-2021, 10:32 PM   #2
phisherman phisherman is offline
King Sandbagger
 

Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $-930000
Quote:
Originally Posted by Monticore View Post
he just doesn't know how to combine it i think he can't make it do the rest.
The point about this though is that when dealing with programming, you sub divide the problem into smaller chunks to solve. This is the bedrock of object oriented programming.

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
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.
Thumbs Up 1 Thumbs Down 0     Reply With Quote
Old 10-13-2021, 10:49 PM   #3
stanleychief stanleychief is offline
Veteran
 
stanleychief's Avatar
 

Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $3876254
Quote:
Originally Posted by phisherman View Post
The point about this though is that when dealing with programming, you sub divide the problem into smaller chunks to solve. This is the bedrock of object oriented programming.

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.
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.
Posts: 1,223
stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.
Thumbs Up 1 Thumbs Down 0     Reply With Quote
Old 10-14-2021, 07:29 AM   #4
phisherman phisherman is offline
King Sandbagger
 

Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $-930000
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,959
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
Old 10-13-2021, 11:00 PM   #5
cdcox cdcox is offline
www.nfl-forecast.com
 
cdcox's Avatar
 

Join Date: Sep 2000
Casino cash: $-478231
Quote:
Originally Posted by Monticore View Post
he just doesn't know how to combine it i think he can't make it do the rest.
Make him show you a working version of 2 and 4. I suspect he does not have those yet. Once he has those working, it is a matter of when he turns on and modulates the light in project 4, he inserts the code from project 2 that modulates its color.

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
cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.cdcox is obviously part of the inner Circle.
Thumbs Up 1 Thumbs Down 0     Reply With Quote
Old 10-13-2021, 11:42 PM   #6
stanleychief stanleychief is offline
Veteran
 
stanleychief's Avatar
 

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);
When I get some down time, and my other hobbies are on hold, I like to tackle IoT projects. A while back, I was doing some prototype work with an ESP32 LyraT board. I wrote an iOS app that would communicate with the board using BLE (low energy bluetooth), prompt the user to select a Wifi SSID, take in the password, and hand that off to the ESP32 board. From there the board would join the Wifi network and initiate a SIP session with a remote VOIP provider. Pressing a button on the ESP32 would initate a SIP voice call to a predetermined number from the device. Essentially, the ESP32 LyraT would become a SIP phone at that point.
Posts: 1,223
stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.
    Reply With Quote
Old 10-14-2021, 04:33 AM   #7
Monticore Monticore is online now
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
Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.
    Reply With Quote
Old 10-14-2021, 09:09 AM   #8
kepp kepp is offline
MVP
 
kepp's Avatar
 

Join Date: Aug 2005
Casino cash: $3519212
Quote:
Originally Posted by Monticore View Post
Appreciate the help guys , not sure if he figured it out i went to bed but will let you know
I think the question is mostly answered in here already, but just an aside as to coding style...he needs to give useful names to his variables. Just saying x, y, z equals something makes it difficult to follow the logic, even in his own head.

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
kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.kepp threw an interception on a screen pass.
    Reply With Quote
Old 10-14-2021, 09:40 AM   #9
stanleychief stanleychief is offline
Veteran
 
stanleychief's Avatar
 

Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $3876254
Quote:
Originally Posted by kepp View Post
I think the question is mostly answered in here already, but just an aside as to coding style...he needs to give useful names to his variables. Just saying x, y, z equals something makes it difficult to follow the logic, even in his own head.

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?
Yep, Serial.print should work as well. I recommended Serial.println, which simply tacks on a linefeed as a convenience.

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
stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.stanleychief has just been standing around suckin' on a big ol' chili dog.
    Reply With Quote
Old 10-14-2021, 10:06 AM   #10
Monticore Monticore is online now
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $-855043
Quote:
Originally Posted by kepp View Post
I think the question is mostly answered in here already, but just an aside as to coding style...he needs to give useful names to his variables. Just saying x, y, z equals something makes it difficult to follow the logic, even in his own head.

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?
I have no idea what anybody is talking about lol but he was trying some of the stuff suggested , not sure where he is at with it , he is working on it at school .

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
Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.Monticore would the whole thing.
    Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump




All times are GMT -6. The time now is 09:14 AM.


This is a test for a client's site.
Fort Worth Texas Process Servers
Covering Arlington, Fort Worth, Grand Prairie and surrounding communities.
Tarrant County, Texas and Johnson County, Texas.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.