hirotakaster
Published © MIT

square

Real time control of a many solenoids.

IntermediateWork in progress448
square

Things used in this project

Hardware components

SparkFun ROB-11015
Minimum is 16, now I use about 500 solenoids.
×16
M5Stack M5SampC3
controller for circuit.
×1
Microchip MCP23017
self-designed PCB board (MCP23017 IO Expander controll 16 solenoids per board). total 34 MPC23017 used.
×1

Story

Read more

Custom parts and enclosures

100_solenoid_enclosure_stl

Sketchfab still processing.

Schematics

100_base_board_circuit

100_base_board_design

Code

sample source code

Arduino
100 solenoid sample source code on Arduino IDE or PlatformIO.
#include <Adafruit_MCP23X17.h>
#define MCP_LEN 1
Adafruit_MCP23X17 mcp[8] = {Adafruit_MCP23X17(), Adafruit_MCP23X17 (),
                            Adafruit_MCP23X17(), Adafruit_MCP23X17 (),
                            Adafruit_MCP23X17(), Adafruit_MCP23X17 (),
                            Adafruit_MCP23X17(), Adafruit_MCP23X17 ()};

void updown(int x, int y, int d) {
  int s = ( x * 10 + y ) / 16 ;
  int p = ( x * 10 + y ) % 16 ;
  mcp[s].digitalWrite(p, HIGH);
  delay(d);
  mcp[s].digitalWrite(p, LOW);
  delay(d);
}

void testfunc() {
  for (int i = 0; i < MCP_LEN; i++) {
    for (int j = 0; j < 16; j++) {
      mcp[i].digitalWrite(j, HIGH);
      delay(500);
      mcp[i].digitalWrite(j, LOW);
      delay(500);
    }
  }
}

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MCP23X17 Test!");
  pinMode(6, INPUT);

  for (int i = 0; i < mcp_len; i++) {
    if (!mcp[i].begin_I2C(0x20+ i)) {
      Serial.print(i);
      Serial.println(" Error.");
    }
    delay(100);
    for (int j = 0; j < 16; j++) {
      mcp[i].pinMode(j, OUTPUT); 
      delay(40);
    }  
  }
  Serial.println("Looping...");
}

void loop() {
  testfunc();
}

Credits

hirotakaster

hirotakaster

2 projects • 3 followers
programmer

Comments