Hi Lolo,
I send here the code for the Arduino extruder, the main Idea is to be able to control via Infrared several independent parts for the extruder:
Fan Buttons:
Several 12V. fans connected in parallel, wired to the Arduino as regular DC motors with variable speed for wire printing. Its a quite basic setup, a transistor varies the current through the digital signal (white cable in the picture). Instructions for tutorials on this regard here (the tutorial includes a thermistor temperature sensor variable activation):
https://www.youtube.com/watch?v=DAn4UguyzfE
Servo Control:
Servo will let us mechanically control the buttons on 3dPen according to this tutorial:
https://www.youtube.com/watch?v=5bHPKU4ybHY
Infrared buttons:
This instructable shows how to download the Infrared Library read the Infrared Signal to define a specific button for a specific action by If statement:
http://www.instructables.com/id/Arduino-Infrared-Remote-tutorial/
and finally a very simple setup for 3D pen extrusion, by sending a digitalWrite signal to the Pen extrusion button. The main issue is to find the polarity that will correctly activate the motor extrusion button for which this tutorial is very useful:
https://3dprint.com/105764/make-3d-printer-from-pen/
Then connect as in the picture, the resistance we will have to adapt to the kind of extrusor we will be using. for the 3d Pen it worked fine with the 100k, instead 10K would not filter the signal and would directly activate the button regardless of the digitalWrite button sent by the infrared. Its important to find the correct resistance.
The Arduino code here:
#include //must copy IRremote library to arduino libraries #include #define plus 0xA3C8EDDB //clockwise rotation button #define minus 0xF076C13B //counter clockwise rotation button #define play 0x20FE4DBB //press button action ///////// #define next 0xD7E84B1B #define prev 0x52A3D41F #define fanOn 0xEE886D7F #define fanOff 0xE318261B #define spindle 0xE5CFBD7F //FOR INFRARED COMMUNICATIONS int RECV_PIN = 11; //IR receiver pin Servo luisservo; int val; //rotation angle bool cwRotation, ccwRotation; //the states of rotation //FOR FAN CONTROL int motorVal; //registers values from 0 to 255 int motorPin = 3; //FOR SPINDLE CONTROL int spindleVal; //registers values from 0 to 255 int spindlePin = 5; IRrecv irrecv(RECV_PIN); decode_results results; void setup() { //INFRARED SIGNAL AND SERVO Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver luisservo.attach(9); //servo pin //FAN CONTROL pinMode(motorPin, OUTPUT); //SPINDLE CONTROL pinMode(spindlePin, OUTPUT); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); irrecv.resume(); // Receive the next value if (results.value == spindle) { digitalWrite(spindlePin,HIGH); delay(5); digitalWrite(spindlePin,LOW); // spindleVal = 100; // analogWrite(spindlePin, spindleVal); // Serial.println(spindleVal); // spindleVal = 0; // analogWrite(spindlePin, spindleVal); // Serial.println(spindleVal); } if (results.value == next) { motorVal = motorVal + 100; if(motorVal>250){ motorVal=250; } analogWrite(motorPin, motorVal); Serial.println(motorVal); } if (results.value == prev) { motorVal = motorVal - 100; if(motorVal<0){ motorVal=0; } analogWrite(motorPin, motorVal); Serial.println(motorVal); } if (results.value == fanOn) { motorVal = 255; analogWrite(motorPin, motorVal); Serial.println(motorVal); } if (results.value == fanOff) { motorVal = 0; analogWrite(motorPin, motorVal); Serial.println(motorVal); } if (results.value == plus) { cwRotation = !cwRotation; //toggle the rotation value ccwRotation = true; //no rotation in this direction } if (results.value == minus) { ccwRotation = !ccwRotation; //toggle the rotation value cwRotation = true; //no rotation in this direction } if (results.value == play) { for (int i=0; i<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span><=90; i=i+90) { luisservo.write(i); delay(100); } } } if (cwRotation && (val != 60)) { val++; //for colockwise button } if (ccwRotation && (val != 0)) { val--; //for counter colockwise button } luisservo.write(val); delay(0); //General speed }