ChiefsPlanet

ChiefsPlanet (https://www.chiefsplanet.com/BB/index.php)
-   Nzoner's Game Room (https://www.chiefsplanet.com/BB/forumdisplay.php?f=1)
-   -   Computers Nerd homework (https://www.chiefsplanet.com/BB/showthread.php?t=340277)

Monticore 10-13-2021 08:27 PM

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

RollChiefsRoll 10-13-2021 08:30 PM

https://c.tenor.com/icBE2WPnDoIAAAAC...y-break-it.gif

digger 10-13-2021 08:32 PM

quick search, might help...




https://learn.sparkfun.com/tutorials...okup-guide/all


good luck, google/bing/duck duck go... ect are you friend went to comes to code, everything is online, (Mostly)...

Bearcat 10-13-2021 08:34 PM

Quote:

Originally Posted by Monticore (Post 15892858)
i am pretty sure this is C/C+

Seems generous.

ClevelandBronco 10-13-2021 08:34 PM

This looks racist. Is it racist?

Monticore 10-13-2021 08:43 PM

Quote:

Originally Posted by Bearcat (Post 15892864)
Seems generous.

I agree I just want his questions to stop .

Monticore 10-13-2021 08:45 PM

Quote:

Originally Posted by digger (Post 15892863)
quick search, might help...




https://learn.sparkfun.com/tutorials...okup-guide/all


good luck, google/bing/duck duck go... ect are you friend went to comes to code, everything is online, (Mostly)...

Thanks .

phisherman 10-13-2021 08:45 PM

It would help to see the formal requirements of the assignment.

Rain Man 10-13-2021 08:47 PM

The kid needs to learn english. I can't understand a word he's saying.

backinblack 10-13-2021 08:48 PM

is it just me or is high school a lot more difficult these days?

have no idea what's happening in the OP

EPodolak 10-13-2021 08:51 PM

Canada must be stopped!

ptlyon 10-13-2021 08:57 PM

Clean up the God damn brackets. Jesus. Heathen.

arrwheader 10-13-2021 09:00 PM

don't speak French and don't code in c++ but So I can see him declaring Integer variables then passing them to a function then based on their return, passing that to another function which I assume returns the color.

Would help if I need what the functions do exactly but seems like he is on the right track at least with the flow.

I mostly code in c#.

Sent from my Pixel 3a using Tapatalk

smithandrew051 10-13-2021 09:04 PM

Be sure to drink your Ovaltine.

arrwheader 10-13-2021 09:06 PM

Also the ifs in c# would look like

If (this)
{
Than that
}
Else if (this and this)
{
That and this
}
Else
{

}

Anyway that's how I'm used to seeing multi if statements in my world


Also he has val 5 equals val 4 and then is comparing them in the if statements? They are the same.


Sent from my Pixel 3a using Tapatalk


All times are GMT -6. The time now is 05:39 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.