Trimpot output to I2c

HI, I am a newbie and do apologize in advance if I sound stupid.
I have recently purchased Freetronics "Eleven" board and 8 channel relay shield.

I would like to switch them on and off sequentially and control the speed via the Trimpot.
Is it possible and what would be the best way to go about?

Thanks in advance

You are failing to think digitally! If you want to use a potentiometer, forget the Arduino now and use a NE555 and a 74HC4017. XD

Potentiometers are passée. In case you have not noticed, they are no longer used as volume controls on audio equipment.

In the digital realm, you use push-buttons for "up" and "down". If you need to retain default settings through power-off, you store the variable in the EEPROM.

You need to study the various tutorials for "blink without delay", "debounce" for buttons and note that some tutorials describe inappropriate things such as having buttons connected to the 5V supply and providing pull-down resistors when they should go to ground and use the built-in pull-ups of the Arduino.

What you describe is not only possible, but dead easy - albeit with a little study!

You mean like #1 on, #1 off, #2 on, #2 off, etc up to #8 on, #8 off?
What speed will the pot control - on time, off time, some other time?
Are on & off the same time, or will the next in sequence be turned on as soon as the previous is off?
What units of time will the 0-1023 from the pot reading correspond to?
Does the speed need to change as soon as the pot is changed, or after the current sequence is done?

Need to flesh out the requirements some.

Writing a simple sequence is easy.

void loop(){
potSpeed = analogRead (A0); // read the pot wiper on A0. outer legs to +5 and Gnd.
digitalWrite(output1, HIGH);  // relay on
delay (potSpeed); // hold for 0 to 1023 mS
digitalWrite (output1,, LOW); // relay off
//and repeat for the other 7
potSpeed = analogRead (A0);
digitalWrite(output2, HIGH);
delay (potSpeed);
digitalWrite (output2, LOW);
potSpeed = analogRead (A0);
digitalWrite(output3, HIGH);
delay (potSpeed);
digitalWrite (output3, LOW);
potSpeed = analogRead (A0);
digitalWrite(output4, HIGH);
delay (potSpeed);
digitalWrite (output4, LOW);
potSpeed = analogRead (A0);
digitalWrite(output5, HIGH);
delay (potSpeed);
digitalWrite (output5,, LOW);
potSpeed = analogRead (A0);
digitalWrite(output6, HIGH);
delay (potSpeed);
digitalWrite (output6, LOW);
potSpeed = analogRead (A0);
digitalWrite(output7 HIGH);
delay (potSpeed);
digitalWrite (output7, LOW);
potSpeed = analogRead (A0);
digitalWrite(output8, HIGH);
delay (potSpeed);
digitalWrite (output8, LOW);
}

and of course do all the pre-setup and void setup( ) stuff.
And this is just screaming for a for loop, maybe an array,
blink without delay for maximum responsiveness.
Lots of room for improvement. But I'm going to bed.

ash999:
HI, I am a newbie and do apologize in advance if I sound stupid.
I have recently purchased Freetronics "Eleven" board and 8 channel relay shield.

8-Channel Relay Driver Shield | Freetronics

I would like to switch them on and off sequentially and control the speed via the Trimpot.
Is it possible and what would be the best way to go about?

Thanks in advance

We have a tutorial that shows how to turn each relay channel on and off in the RELAY8: quickstart guide:

Please disregard the sketch in crossroads' post. Below is a quick sketch for you that takes the reading from analogue pin zero (which is connected to the centre pin of your trimpot. with the others going to 5V and GND) and uses the value as the delay between the sequential switching.
You can always add some code after reading the value for analogue pin zero to increase/decrease the delay period.

#include "Wire.h"
#define I2C_ADDR  0x20  // 0x20 is the address with all jumpers removed

int trimpot;

void setup()
{
  Wire.begin(); // Wake up I2C bus

  // Set I/O bank A to outputs
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x00); // IODIRA register
  Wire.write(0x00); // Set all of bank A to outputs
  Wire.endTransmission();
}

void loop()
{
   sendValueToLatch(1);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(2);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(4);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);      
   
   sendValueToLatch(8);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(16);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(32);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(64);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);   
   
   sendValueToLatch(128);
   trimpot=analogRead(0);
   delay(trimpot);   
   sendValueToLatch(0);      
}

void sendValueToLatch(int latchValue)
{
  Wire.beginTransmission(I2C_ADDR);
  Wire.write(0x12);        // Select GPIOA
  Wire.write(latchValue);  // Send value to bank A
  Wire.endTransmission();
}

Hmm, guess I should have opened the link (was blocked where I was typing from).
That's not at all what I was picturing for a relay shield.

CrossRoads:
Hmm, guess I should have opened the link (was blocked where I was typing from).
That's not at all what I was picturing for a relay shield.

I made the same mistake initially - not that I was blocked, just didn't recall what that shield was.

It contains an I2C interface, so you have to have a microprocessor to interface with it.

Much simpler to do what I understand to be the original task, with a plain relay module (not shield) and two cheap ICs on a proto board.