Skip to content

Instantly share code, notes, and snippets.

@smirgol
smirgol / fan_control.py
Created February 17, 2021 11:23
Python 3 script to control Arduino PWM
#!/usr/bin/python3
"""Control an Arduino over the USB port."""
# Based on:
# usb.py
# Created by John Woolsey on 12/17/2019.
# Copyright (c) 2019 Woolsey Workshop. All rights reserved.
# Reference:
# https://www.woolseyworkshop.com/2020/02/05/controlling-an-arduino-from-a-raspberry-pi/
@smirgol
smirgol / printer_controller.ino
Created February 17, 2021 11:19
Arduino Uno code for controlling two PWM fans
#include <TimerOne.h>
// PWM Pins
#define PIN_FAN1_OUTPUT_PWM 9 // PWM Signal to fan 1 - OUTPUT FAN
#define PIN_FAN2_OUTPUT_PWM 10 // PWM Signal to fan 2 - INPUT FAN
#define PWM_MAX_VALUE 1023 // maximum value of analog pwm throttle signal
// Set these to the defaults that you want on startup (0-255)
int pwm_value_fan1 = 220;
int pwm_value_fan2 = 0;