Adafruit Servo Code With Solenoid

Keenan Gray
testing_for_steven.ino

Adafruit LIbrary Reference

https://learn.adafruit.com/16-channel-pwm-servo-driver/library-reference

Forum post with wiring diagram 

https://forums.adafruit.com/viewtopic.php?t=123020



#include <Wire.h>#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);// you can also call it with a different address you want//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
#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)#define USMIN 600      // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150#define USMAX 2400     // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600


#define SERVO_FREQ 500  // Analog servos run at ~50 Hz updates
int servonum = 0;
void setup() {  Serial.begin(9600);  Serial.println("16 channel PWM test!");
  pwm.begin();  //pwm.setOscillatorFrequency(27000000);  pwm.setPWMFreq(SERVO_FREQ);
  delay(10);}
void loop() {  // Drive each servo one at a time using setPWM()  Serial.println(servonum);
  pwm.setPWM(servonum, 04096); //Signal to for off  delay(500);
  pwm.setPWM(servonum, 40960); //Signal for on!    delay(500);
}




Hardware components :
12V solenoids -- LINK

Adafruit 16 channel i2c driver -- LINK

Mosfet --  IRF610 -- LINK

Diode -- 1n4148 -- LINK

Code Club

Keenan Gray

CODE CLUB

CODE CLUB

CODE CLUB