Hoffman Amplifiers Tube Amplifier Forum

Other Stuff => Electronic Projects => Topic started by: EL34 on July 20, 2022, 03:03:45 pm

Title: Arduino test: Turning amp pots with a servo
Post by: EL34 on July 20, 2022, 03:03:45 pm
I did a simple two button test just to see how much power it took to turn an amp pot

This tiny 180 degree servo had no problem turning a 1ma amp pot

Here's the Arduino code I wrote for this bench test

Code: [Select]

// Test: Servo turning an amp pot

#include <Servo.h> // include the Servo library
// Twelve servo objects can be created on most boards
Servo myServo;  // create servo object to control a servo

int position = 0; // variable to store the servo position

// constants won't change. They're used here to set pin numbers:
const int Button0 = 2;  // the number of the pushbutton pin
const int Button1 = 3;  // the number of the pushbutton pin
const int ledPin =  13; // The number of the Arduino LED pin

// variables for the push buttons
int ButtonState0 = 0;
int ButtonState1 = 0;

void setup()
{
  //Serial.begin(115200); // open a serial connection to your computer
  myServo.attach(9); // attaches the servo on Arduino pin 9 to the servo object
 
  pinMode(ledPin, OUTPUT); // initialize the Arduino LED pin as an output

  // initialize the push button pins as inputs
  pinMode(Button0, INPUT);
  pinMode(Button1, INPUT);

  myServo.write(position); // go to zero on start up
}

void loop()
{
  // read the state of the push buttons
  ButtonState0 = digitalRead(Button0);
  ButtonState1 = digitalRead(Button1);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (ButtonState0 == HIGH)
  {
    digitalWrite(ledPin, HIGH); // turn Arduino LED on
    myServo.write(10); // go to 10 degree
  }


  else if (ButtonState1 == HIGH)
  {
    digitalWrite(ledPin, HIGH); // turn Arduino LED on
    myServo.write(170); // go to 170 degree
  }


  else
  {
    digitalWrite(ledPin, LOW); // turn Arduino LED off
  }

}

And here 's the video with more info
It is 1440p


Title: Re: Arduino test: Turning amp pots with a servo
Post by: EL34 on July 31, 2022, 02:52:18 pm
Arduino Servo Experiment #2

Setting up preset buttons to turn multiple servos to different positions.

I attached the Arduino code as a .txt text file -  Servo5.txt
Rename the file to .ino to load into the Arduino IDE - Servo5.ino

Filmed at 1440p HD

Title: Re: Arduino test: Turning amp pots with a servo
Post by: EL34 on July 31, 2022, 03:05:01 pm
Here's how to do the multiple buttons and one data wire using a voltage divider circuit
Just add more buttons and more resistors
The resistors are all the same value
I am using 220 ohm 1/4 watt metal films in my test setup

The voltage drop reading will be different at each junction depending on how many switches you have
Those values are set in the Arduino code that I attached to the post above
Title: Re: Arduino test: Turning amp pots with a servo
Post by: shooter on August 01, 2022, 03:09:33 am
i use a 4 position DIP switch, feeding the Pic controller I use. 
If I can't get it with 16 combinations i'm over thinking it  :icon_biggrin: