My problem is trying to get BTN8 slider bar to control a pin output as if it was a potentiometer.
The code below is one of many ways I have tried this and this is the closest i have gotten. it will upload to the Arduino just will not give me any thing on the pin.
I am trying to get this to control a pin as if the BTN8 slider bar is a potentiometer connected to a input like A1 or something like that.
Code for where to start the slide bar.
Serial.begin(9600);
TSC.setBackColor(TSC.createColor(0, 0, 0)); // change the default background color
TSC.init(); // make sure everything get initialized
btn7.setValue(.5); // change the value on one of the sliders
btn7.setPadding(5); // change the padding on one of the sliders
btn8.setValue(val); // change the value on one of the sliders
btn8.setPadding(5); // change the padding on one of the sliders
curMenu->draw(); // put up the main menu
}
Code for what the slidebar should do.
else if(btn8.process()){
digitalWrite(pin53, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(pin53, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
}
Why are the sliders called btn7 and btn8? Why aren't the buttons called slider1 through slider6?
The btn8.process() call returns true if the slider was touched. You then need to call the getValue() function to actually get the slider position (between 0 and 1). Where are you doing that?
As near as I can tell, val never changes from the initial value of 0, so I don't see how you can know if anything is happening. Of course, why val is an int is a mystery, too. The setValue() method expects a float and the delay() function expects an unsigned long.
void checkButtons(){
if(backFromGfx.process()){ // return from the graphics function screen
curMenu = &mainMenu;
TSC.clearScreen();
curMenu->draw();
}
else if(backFromBtns.process()){ // return from the buttons screen
curMenu = &mainMenu;
TSC.clearScreen();
curMenu->draw();
}
else if(backFromLbls.process()){ // return from the labels screen
curMenu = &mainMenu;
TSC.clearScreen();
curMenu->draw();
}
else if(btn1.process()){
//do something
}
else if(btn2.process()){
//do something
}
else if(btn3.process()){
//do something
}
else if(btn4.process()){
//do something
}
else if(btn5.process()){
//do something
}
else if(btn6.process()){
//do something
}
else if(btn7.process()){
//do something
}
else if(btn8.process()){
if ((btn8.getValue()!=0))
digitalWrite(pin53, HIGH); // turn the ledPin on
delay(btn8.getValue()); // stop the program for some time
digitalWrite(pin53, LOW); // turn the ledPin off
delay(btn8.getValue()); // stop the program for some time)
}
}
thank you for some reason i could not think and yes i was missing the getValue() that fixed a part of what I was trying to do now i have to get this to loop till its set to zero but i should be able to figure that out and thank you again.