Home Mail Discord Chat
Go Back   ChiefsPlanet > The Lounge

Reply
 
Thread Tools Display Modes
Old 10-13-2021, 08:27 PM  
Monticore Monticore is offline
I love your mom
 
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $75
Nerd homework

My son needs help with his homework and I know nothing about coding , he is trying to get a RGB strip to light up with increasing intensity as more pressure is applied to sensor while also randomizing a series of colors .(llike a light up shoe)

this is what he has which he knows is horribly wrong i am pretty sure this is C/C+, this is his hisrt ever coding class so his knowledge is fairly limited.
I also know it is in french but it might still make sense to some of you

int valeur1 = 0; //variable de type integer pour enregistrer analog A0
int valeur2 = 0; //variable de type integer pour enregistrer analog A0
int valeur3 = 0;
int valeur4 = 0;
int valeur5 = 0;

void setup() {

Serial.begin(9600); //commence le serial pour ecrire les données
pinMode(A0,INPUT_PULLUP); //prepare A0 pour le pressure sensor
pinMode(3,OUTPUT); //prepare pin 3 pour output de 5V
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
}

void loop() {

valeur1 = analogRead(A0);
delay(1000);
valeur2 = (200/valeur1);
valeur3 = (valeur2*valeur2);




valeur4 = random(255);
valeur5 = valeur4;

if (valeur4 > valeur5){
valeur5--;
analogWrite(3,valeur5);

}

if (valeur4 < valeur5){
valeur5++;
analogWrite(3,valeur5);

}

if (valeur4 == valeur5){

valeur5;
analogWrite(3,valeur5);

}







if (valeur4 > valeur5){
valeur5++;
analogWrite(5,valeur5);

}

if (valeur4 < valeur5){
valeur5--;
analogWrite(5,valeur5);

}

if (valeur4 == valeur5){

analogWrite(5,valeur5);

}








if (valeur4 > valeur1){
valeur5++;
analogWrite(6,valeur5);

}

if (valeur4 < valeur5){
valeur5--;
analogWrite(6,valeur5);

}

if (valeur4 == valeur5){

analogWrite(6,valeur5);

}

}

would appreciate any help or insults
Posts: 3,913
Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.
  Reply With Quote
Old 10-14-2021, 11:18 AM   #46
ptlyon ptlyon is offline
Bono & Grbac wasn't enough
 

Join Date: Oct 2000
Location: Sioux City, IA
Casino cash: $10023929
Quote:
Originally Posted by stanleychief View Post
I just hope this kid renames the variables before turning in the code. If I were grading the assignment, I'd be raising an eyebrow if the variables were French.

I once worked on some client's code, which was apparently written by a guy named Eric. Every variable in his code was prefixed with 'eric'. So the SQL DB connection was 'ericDbConn', and the result set was 'ericDbResult', the datarow object was 'ericDbRow', etc.

I thought that was pretty damned hilarious!
What was this piece of code written for, if I may ask?
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertise here: $19.99 a month
Posts: 26,943
ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.
    Reply With Quote
Old 10-14-2021, 11:21 AM   #47
Otter Otter is offline
Live free or die hard
 
Otter's Avatar
 

Join Date: Sep 2000
Location: Durango, CO
Casino cash: $19482
Curly brackets?

Apparently it's been awhile since I dipped my toe in C world so I'll just say make the code more linear and unless he's coding for a French person use the English Language for comments.
__________________
Quote:
Originally Posted by Otter View Post
If the Chiefs manage to grab Mahomes I officially claim him as my "adopt a Chief".
Posts: 22,212
Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.Otter is obviously part of the inner Circle.
    Reply With Quote
Old 10-14-2021, 11:32 AM   #48
stanleychief stanleychief is offline
Starter
 
stanleychief's Avatar
 

Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $7400
Quote:
Originally Posted by ptlyon View Post
What was this piece of code written for, if I may ask?
It was a long time ago, but I believe that particular code was embedded in a classic ASP page. He was fetching options from the database to populate a select tag on a form.

I recall that the guy left a lot of comments too, which is usually a good thing, but his comments were unnecessary, as they didn't explain anything helpful. Example:

Code:
// This is the database connection
Dim ericDbConn = Server.CreateObject("ADODB.Connection")
Pretty obvious, given the naming, and straight-forward variable assignment. Struck me as if they were written by someone just out of school. The client was a large regional grocery store chain.
Posts: 914
stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.
    Reply With Quote
Old 10-14-2021, 11:38 AM   #49
ptlyon ptlyon is offline
Bono & Grbac wasn't enough
 

Join Date: Oct 2000
Location: Sioux City, IA
Casino cash: $10023929
Quote:
Originally Posted by stanleychief View Post
It was a long time ago, but I believe that particular code was embedded in a classic ASP page. He was fetching options from the database to populate a select tag on a form.

I recall that the guy left a lot of comments too, which is usually a good thing, but his comments were unnecessary, as they didn't explain anything helpful. Example:

Code:
// This is the database connection
Dim ericDbConn = Server.CreateObject("ADODB.Connection")
Pretty obvious, given the naming, and straight-forward variable assignment. Struck me as if they were written by someone just out of school. The client was a large regional grocery store chain.
That was my first thought as well. Naming conventions have always been my downfall. I've learned some, but still sometimes go back to what makes sense to me at the time.
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertise here: $19.99 a month
Posts: 26,943
ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.
    Reply With Quote
Old 10-14-2021, 11:44 AM   #50
stanleychief stanleychief is offline
Starter
 
stanleychief's Avatar
 

Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $7400
Quote:
Originally Posted by ptlyon View Post
That was my first thought as well. Naming conventions have always been my downfall. I've learned some, but still sometimes go back to what makes sense to me at the time.
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton

https://martinfowler.com/bliki/TwoHardThings.html
Posts: 914
stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.
    Reply With Quote
Old 10-14-2021, 11:53 AM   #51
Monticore Monticore is offline
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $75
Quote:
Originally Posted by Otter View Post
Curly brackets?

Apparently it's been awhile since I dipped my toe in C world so I'll just say make the code more linear and unless he's coding for a French person use the English Language for comments.
French Highschool so the French is mandatory , it sucks lol.
Posts: 3,913
Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.
    Reply With Quote
Old 10-14-2021, 11:56 AM   #52
Monticore Monticore is offline
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $75
Quote:
Originally Posted by stanleychief View Post
There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton

https://martinfowler.com/bliki/TwoHardThings.html
Well he managed to figure it out , he says it worked like it was supposed to but he said he didn't code it like the teacher did , he said the tips in here were helpful.

thanks fellas .
Posts: 3,913
Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore 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, 12:03 PM   #53
stanleychief stanleychief is offline
Starter
 
stanleychief's Avatar
 

Join Date: Aug 2002
Location: Kansas City, MO
Casino cash: $7400
Quote:
Originally Posted by Monticore View Post
French Highschool so the French is mandatory , it sucks lol.
Oh, completely missed that! I assumed that he found an example of the code in French and was trying to use it in an English computer science class. He should probably keep those variable names in French then.

Glad to hear that this helped. Is your son looking to pursue a career in computer science, or is this just one of his classes? Programming can be intimidating at first, but if he sticks with it, things will become easier. All that gibberish starts to make sense at some point.
Posts: 914
stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.stanleychief must have mowed badgirl's lawn.
    Reply With Quote
Old 10-14-2021, 12:20 PM   #54
Monticore Monticore is offline
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $75
Quote:
Originally Posted by stanleychief View Post
Oh, completely missed that! I assumed that he found an example of the code in French and was trying to use it in an English computer science class. He should probably keep those variable names in French then.

Glad to hear that this helped. Is your son looking to pursue a career in computer science, or is this just one of his classes? Programming can be intimidating at first, but if he sticks with it, things will become easier. All that gibberish starts to make sense at some point.
I recommended he try it out since he always liked the idea of maybe getting into robotics , he is very strong in math, physics and chemistry and likes problem solving ,unfortunately it is a subject my wife or I can't help much with , he just procrastinated a bit and was getting flustered and was hoping a tip or two might get him back on the right track which it did.
Posts: 3,913
Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.
    Reply With Quote
Old 10-14-2021, 12:41 PM   #55
ptlyon ptlyon is offline
Bono & Grbac wasn't enough
 

Join Date: Oct 2000
Location: Sioux City, IA
Casino cash: $10023929
Not sure how many more labs he will have, but here's a piece of advice our instructors gave us.

When you're trying to work out a problem with your code, step away. Do something else, get your mind off of it. Sometimes clearing your mind will bring you the answer.

Also when you go to bed, put a pad and pen next to your bed. You would be surprised how many times that worked for me, waking up with either an answer to a problem or an idea of how to write a program in the middle of the night.

Good luck.
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertise here: $19.99 a month
Posts: 26,943
ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.ptlyon is obviously part of the inner Circle.
    Reply With Quote
Old 10-14-2021, 12:55 PM   #56
Monticore Monticore is offline
I love your mom
 

Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $75
Quote:
Originally Posted by ptlyon View Post
Not sure how many more labs he will have, but here's a piece of advice our instructors gave us.

When you're trying to work out a problem with your code, step away. Do something else, get your mind off of it. Sometimes clearing your mind will bring you the answer.

Also when you go to bed, put a pad and pen next to your bed. You would be surprised how many times that worked for me, waking up with either an answer to a problem or an idea of how to write a program in the middle of the night.

Good luck.
Exactly what I was trying to explain to him last night , he is still young and stubborn he will learn.
Posts: 3,913
Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.Monticore has just been standing around suckin' on a big ol' chili dog.
    Reply With Quote
Reply

Thread Tools
Display Modes

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 07:13 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 - 2021, vBulletin Solutions, Inc.