multiplexer to servo controller guidance needed

ok so I'm kind of a noob and in need of some guidance, I have a 16 channel multiplexer with pin C0 connected to a pot... I need some guidance as to how I would pass this signal across to my servo board

I think wires will probably be involved but without knowing what "16 channel multiplexer" and what "servo board" you're talking about I can't really be more definite.

Steve

attached above is a fritzing jpeg showing how I have it set up the servo board functions with the adafruit 16 controller library I just need to be aimed in the correct direction at this point I have no clue how to get a single POT to send a signal to a single servo. i should be able to figure it out from there. but i cant find and tutorials on the subject

It sounds like you are doing what the File->Examples->Servo->Knob example does except you are using the multiplexer to read the analog value and the adafruit 16 controller library to write a position to the servo.

Have you found an example of how to read an analog signal from your multiplexer? If not, find one. Replace the simple analogRead() in the Knob example with that.

Have you found an example of how to write to a servo with the adafruit 16 controller library? If not, find one. Replace the simple servo.write() in the Knob example with that.

my problem on the read side is how to pull from individual channels I legitimately dove into Arduino a week ago and this particular task is just beyond me in most aspects if i can get 1 servo working i can figure it out from there but as someone whos new to all of this this task has become mind boggling but i have to succed in this in order to make the project im working on function.

**
* This example demonstrates how to read analog signals
* It assumes there are potentiometers connected
* to the 16 channels of the 74HC4067 mux/demux
* 
* For more about the interface of the library go to
* https://github.com/pAIgn10/MUX74HC4067
*/

#include "MUX74HC4067.h"

// Creates a MUX74HC4067 instance
// 1st argument is the Arduino PIN to which the EN pin connects
// 2nd-5th arguments are the Arduino PINs to which the S0-S3 pins connect
MUX74HC4067 mux(7, 8, 9, 10, 11);

void setup()
{
Serial.begin(9600);  // Initializes serial port
   // Waits for serial port to connect. Needed for Leonardo only
   while ( !Serial ) ;

// Configures how the SIG pin will be interfaced
// e.g. The SIG pin connects to PIN A0 on the Arduino,
//      and PIN A0 is a analog input
mux.signalPin(A0, INPUT, ANALOG);
}

// Reads the 16 channels and reports on the serial monitor
// the corresponding value read by the A/D converter
void loop()
{
int data;

for (byte i = 0; i < 16; ++i)
{
// Reads from channel i. Returns a value from 0 to 1023
data = mux.read(i);

Serial.print("Potentiometer at channel ");
Serial.print(i);
Serial.print(" is at ");
Serial.print((double)(data) * 100 / 1023);
Serial.println("%%");
}
Serial.println();

delay(1500);
}

my problem on the write side is essentially the same

/*************************************************** 
 This is an example for our Adafruit 16-channel PWM & Servo driver
 Servo test - this will drive 8 servos, one after the other on the
 first 8 pins of the PCA9685

 Pick one up today in the adafruit shop!
 ------> http://www.adafruit.com/products/815
 
 These drivers use I2C to communicate, 2 pins are required to  
 interface.

 Adafruit invests time and resources providing this open source code, 
 please support Adafruit and open-source hardware by purchasing 
 products from Adafruit!

 Written by Limor Fried/Ladyada for Adafruit Industries.  
 BSD license, all text above must be included in any redistribution[/sub]
****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
// you can also call it with a different address and I2C interface
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, &Wire);

// Depending on your servo make, the pulse width min and max may vary, you 
// want these to be as small/large as possible without hitting the hard stop
// for max range. You'll have to tweak them as necessary to match the servos you
// have!
#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)

// our servo # counter
uint8_t servonum = 0;

void setup() {
 Serial.begin(9600);
 Serial.println("8 channel Servo test!");

 pwm.begin();
 
 pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates

 delay(10);
}

// you can use this function if you'd like to set the pulse length in seconds
// e.g. setServoPulse(0, 0.001) is a ~1 millisecond pulse width. its not precise!
void setServoPulse(uint8_t n, double pulse) {
 double pulselength;
 
 pulselength = 1000000;   // 1,000,000 us per second
 pulselength /= 60;   // 60 Hz
 Serial.print(pulselength); Serial.println(" us per period"); 
 pulselength /= 4096;  // 12 bits of resolution
 Serial.print(pulselength); Serial.println(" us per bit"); 
 pulse *= 1000000;  // convert to us
 pulse /= pulselength;
 Serial.println(pulse);
 pwm.setPWM(n, 0, pulse);
}

void loop() {
 // Drive each servo one at a time
 Serial.println(servonum);
 for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
   pwm.setPWM(servonum, 0, pulselen);
 }

 delay(500);
 for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
   pwm.setPWM(servonum, 0, pulselen);
 }

 delay(500);

 servonum ++;
 if (servonum > 7) servonum = 0;
}

The Adafruit example is a little hard to follow. Here a an example I just wrote. It has two functions for setting the servo position:
ServoWrite(servoNum, degrees); // 0-180 like servo.write()

ServoWriteMicroseconds(servoNum, pulseLen); // 1000-2000 like servo.writeMicroseconds()

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>


const double PulseRepeatRate = 50.0;  // 50Hz repeat rate
const double PulseRepeatPeriodMicroseconds = 1000000.0 / PulseRepeatRate;
const double MicrosecondsPerCount = PulseRepeatPeriodMicroseconds / 4096.0;


// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver ServoDriver;


void ServoWriteMicroseconds(uint8_t servoNumber, uint16_t microseconds)
{
  ServoDriver.setPWM(servoNumber, 0, microseconds / MicrosecondsPerCount);
}


void ServoWrite(uint8_t servoNumber, int16_t degrees)
{
  uint16_t microseconds = map(degrees, 0, 180, 1000, 2000);
  ServoWriteMicroseconds(servoNumber, microseconds);
}


void setup()
{
  ServoDriver.begin();
  ServoDriver.setPWMFreq(PulseRepeatRate);
}

void loop()
{
  static byte servoNum = 0;


  // Sweep min to max, by microseconds
  for (uint16_t pulselen = 1000; pulselen <= 2000; pulselen++)
  {
    ServoWriteMicroseconds(servoNum, pulselen);
    delay(15);
  }


  delay(500);


  // Sweep max to min, by degrees (this will move faster since the range is smaller)
  for (int16_t degrees = 180; degrees >= 0; degrees--)
  {
    ServoWrite(servoNum, degrees);
    delay(15);
  }


  delay(500);


  // After the 8th servo (#7) go back to the first (#0)
  if (++servoNum > 7)
    servoNum = 0;
}

currently, I have managed to make the mux function on my setup running a servo from digital pin five...
from here i still cannot assemble in my brain how i can take a mux read from seven and send that in the form of a pulse wave or whatever to a servo at location zero on the servo board im missing something and clearly it's my lack of coding knowledge messing me up.... still not bad for one week however the code example you provided resulted in a twitchy servo thank you very much for the time you have put in to help me though im sure us noobs can be frustrating

/*

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <Servo.h>
#include "MUX74HC4067.h"



Servo myservo;  // create servo object to control a servo
MUX74HC4067 mux(7, 8, 9, 10, 11);  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup() {
myservo.attach(5); // attaches the servo on pin 5 to the servo object
mux.signalPin(A0, INPUT, ANALOG);
{
}


}

void loop() {
  
  val = mux.read(7);          // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // 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

Delta_G pointing to something in a foreign language and saying it's obvious doesn't provide much guidance I already could see where the servo number is that doesn't mean that after a week I fully speak programming at this point thanks for your help but id rather not try and figure it out if I'm going to be condescended to. I'm sure after a week you were Bjarne Stroustrup but I feel your approach to "helping" is a little less than helpful and in fact slightly discouraging. unlike the approach that was taken by john. by all means, if you have an assistive comment or maybe even a small contribution to the program I'm working on by all means but beyond that have a good one.

This is one way to control servo 0 with a pot on multiplexer input 7:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>


#include "MUX74HC4067.h"


// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();


const double PulseRepeatRate = 50.0;  // 50Hz repeat rate
const double PulseRepeatPeriodMicroseconds = 1000000.0 / PulseRepeatRate;
const double MicrosecondsPerCount = PulseRepeatPeriodMicroseconds / 4096.0;


const int SERVOMIN = 1000 / MicrosecondsPerCount; // this is the 'minimum' pulse length count (out of 4096)
const int SERVOMAX = 2000 / MicrosecondsPerCount; // this is the 'maximum' pulse length count (out of 4096)


MUX74HC4067 mux(7, 8, 9, 10, 11);  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
const byte MultiplexerInput = 7;
const byte ServoOutput = 0;


void setup()
{
  pwm.begin();
  pwm.setPWMFreq(PulseRepeatRate);  // Analog servos run at ~50 Hz (20 millisecond) updates


  mux.signalPin(A0, INPUT, ANALOG);
}


void loop()
{
  val = mux.read(MultiplexerInput);          // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, SERVOMIN, SERVOMAX);     // scale it to use it with the servo
  pwm.setPWM(ServoOutput, 0, val);      // sets the servo position according to the scaled value
  delay(15);  // waits for the servo to get there
}