I have put together a schematic and code for an IR controlled 12VDC fan and would like to see if I am headed in the right direction. I am only looking to turn the fan off and on not to control the speed. I am sure that the symbols may not be 100% correct but I can't get to fritzing at work so I had to cut and paste with MSpaint and the code is below.
Your right crossroads I mis-spoke by saying schematic. The parts are (from top to bottom, L to R) IR Receiver, MOSFET, power supply for motor, and motor/fan. There is also a resistor for the IR Receiver and a Diode for the MOSFET.
@SirBow2
I want the fan to be on until turned off by another press of the remote.
if(results.value == -2094865891)
{
digitalWrite(transistorPin,!digitalRead(transistorPin)); // set the Fan opposite of current state when button pressed.
}
you may want to add some delays/debounce etc so that it doesnt change really fast.
ok I updated the code a little bit. This is a result of testing just the IR receiver
#include <IRremote.h>
int RECV_PIN = 9;
int transistorPin = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(transistorPin, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
if(results.value <= -2094865891)
{
digitalWrite(transistorPin,!digitalRead(transistorPin)); // set the Fan opposite of current state when button pressed.
delay(200);
}
irrecv.resume(); // Receive the next value
}
}