never used a switch case statement before I basically want to increase a PWM value with a button press. however im getting a error. the example code in the IDE wasn't helpful to me.
if (dimmerPin==LOW);{
delay(10);
count++;
if (count = 4);{
count = 0;
}
}
switch
case count = 0
dimmerVal = 64;
break;
case count = 1:
dimmerVal = 128;
break;
case count = 2:
dimmerVal = 192;
break;
case count = 3:
dimmerVal = 255;
When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).
int count;
int dimmerVal;
int ledPin = 0; //analogWrite
int dimmerPin =3; //digitalRead
int lightPin = 2; //analogRead
int auxPin = 4; // digitalWrite
void setup() {
// put your setup code here, to run once:
pinMode(dimmerPin,INPUT);
pinMode(lightPin,INPUT);
pinMode(ledPin,OUTPUT);
pinMode(auxPin,OUTPUT);
count = 3;
}
void loop() {
// put your main code here, to run repeatedly:
if (dimmerPin,LOW);{
delay(25);
count++;
if (count == 4);{
count = 0;
}
}
switch (count){
case 0:
dimmerVal = 0;
break;
case 1:
dimmerVal = 85;
break;
case 2:
dimmerVal = 170;
break;
case 3:
dimmerVal = 255;
break;
}
}
RayLivingston:
It may compile without errors, but this is still not going to do what you want it to...
if (dimmerPin,LOW);{
Regards,
Ray L.
yes thank you, it has been corrected. sometimes I get in a hurry and forget the little things.
I did grasp the idea of how to set up a switch case, which was my original predicament
LandonW:
yes thank you, it has been corrected. sometimes I get in a hurry and forget the little things.
I did grasp the idea of how to set up a switch case, which was my original predicament
Did you also note that the ; does NOT belong in that statement?