|
|
10-13-2021, 08:27 PM | Topic Starter |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $1324957
|
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: 6,907
|
10-13-2021, 08:30 PM | #2 |
I don’t care for Auburn
Join Date: Aug 2014
Location: Sweet Home Alabama
Casino cash: $3590340
|
|
Posts: 7,009
|
10-13-2021, 08:32 PM | #3 |
Thread I will end you.......
Join Date: Apr 2007
Location: Kansas City, KS
Casino cash: $322608
VARSITY
|
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)...
__________________
Patrick Mahomes II MVP 2X Super Bowl MVP 3x Travis Kelce TE GOAT |
Posts: 9,759
|
10-13-2021, 08:45 PM | #4 | |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $1324957
|
Quote:
|
|
Posts: 6,907
|
10-13-2021, 08:34 PM | #5 |
Would an idiot do that?
Join Date: Nov 2000
Location: Arizona
Casino cash: $1334931
|
|
Posts: 56,554
|
3 0 |
10-13-2021, 08:43 PM | #6 |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $1324957
|
|
Posts: 6,907
|
10-13-2021, 08:34 PM | #7 |
I'm with the banned.
Join Date: Sep 2006
Casino cash: $5658955
|
This looks racist. Is it racist?
__________________
"Faith and reason are like two wings on which the human spirit rises to the contemplation of truth ..." – Pope Saint John Paul II |
Posts: 28,113
|
3 0 |
10-13-2021, 08:45 PM | #8 |
King Sandbagger
Join Date: Feb 2003
Location: The Summit, MO
Casino cash: $115484
|
It would help to see the formal requirements of the assignment.
|
Posts: 3,893
|
10-13-2021, 09:14 PM | #9 |
I love your mom
Join Date: Feb 2020
Location: Sturgeon Falls, Ontario
Casino cash: $1324957
|
it would all be in french lol , he needs the strip to light up in random rbg colors while also increasing in intensity of brightness equal to pressure on a sensor, he can do both tasks separately .
|
Posts: 6,907
|
10-13-2021, 08:47 PM | #10 |
NFL's #1 Ermines Fan
Join Date: Jul 2001
Location: My house
Casino cash: $1818491
VARSITY
|
The kid needs to learn english. I can't understand a word he's saying.
__________________
Active fan of the greatest team in NFL history. |
Posts: 142,654
|
3 0 |
10-13-2021, 08:48 PM | #11 |
go to work wasted
Join Date: Jan 2020
Location: Boise
Casino cash: $2110400
|
is it just me or is high school a lot more difficult these days?
have no idea what's happening in the OP |
Posts: 2,763
|
10-13-2021, 08:51 PM | #12 |
Spooky Action
Join Date: Dec 2003
Casino cash: $1152558
|
Canada must be stopped!
|
Posts: 6,404
|
10-13-2021, 08:57 PM | #13 |
Bono & Grbac wasn't enough
Join Date: Oct 2000
Location: Sioux City, IA
Casino cash: $11603829
|
Clean up the God damn brackets. Jesus. Heathen.
__________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Advertise here: $19.99 a month |
Posts: 36,381
|
10-13-2021, 09:00 PM | #14 |
Veteran
Join Date: Dec 2011
Casino cash: $2086613
|
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 |
Posts: 3,486
|
10-13-2021, 09:04 PM | #15 |
I Like The Kansas City Chiefs
Join Date: Nov 2017
Location: Shawnee, KS
Casino cash: $1734400
|
Be sure to drink your Ovaltine.
__________________
My 2024 Adopt a Chief: Leo Chenal Holy Hat! |
Posts: 27,286
|
2 0 |
|
|