Thread: Computers Nerd homework
View Single Post
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: $2804957
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,579
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