Advertisement
microrobotics

Power Mosfet Module - 15A 400W

May 9th, 2023
3,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Arduino Power Mosfet Driver with Two Parallel MOSFETs
  2.  
  3. #include <Arduino.h>
  4.  
  5. // Pins
  6. const int pwmPin = 9;  // PWM signal to the gate driver IC
  7.  
  8. void setup() {
  9.   // Set up pins
  10.   pinMode(pwmPin, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14.   // Adjust the duty cycle to control the power output
  15.   int dutyCycle = map(analogRead(A0), 0, 1023, 0, 255);
  16.  
  17.   // Write the duty cycle to the PWM pin
  18.   analogWrite(pwmPin, dutyCycle);
  19.  
  20.   // Optional: Add a delay to control the update rate
  21.   delay(20);
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement