/*This software is provided in an “AS IS” condition,NO WARRANTIES in any form apply to this software. picmicrolab.com 10.12.2017 *************************************************************************************************************** Arduino PWM Fan Controller */ int FanPWM = 9; // Fan PWM pin int PushButtonInput1 = 2; // Push button - set PWM Fan speed LOW int PushButtonInput2 = 3; // Push button - set PWM Fan speed Medium int PushButtonInput3 = 4; // Push button - set PWM Fan speed High void setup() { pinMode(FanPWM, OUTPUT); pinMode(PushButtonInput1,INPUT_PULLUP); pinMode(PushButtonInput2,INPUT_PULLUP); pinMode(PushButtonInput3,INPUT_PULLUP); } void loop() { //-----------------LOW---------------------- if(digitalRead(PushButtonInput1) == LOW) analogWrite(FanPWM, 1); //----------------Medium--------------------- if(digitalRead(PushButtonInput2) == LOW) analogWrite(FanPWM, 127); //------------------High----------------------- if(digitalRead(PushButtonInput3) == LOW) analogWrite(FanPWM, 255); //--------------------------------------------- }