What I want is something that I think a lot of people use, but I can't find any information on. When I pres a tactile switch I want it to act like it's being held down. Example:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
int knobbutton = 22; // pin that the tactile switch used to activate the knob control
int knobbuttonval;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
knobbuttonval = digitalRead (knobbutton);
if (knobbuttonval gets pressed once)
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}
}
So I basically just don't know what to put in the brackets for the "if" statement. Excuse me if I used incorrect terms, I'm rather new to this.
Thanks