After some work, the compass and solenoids array is ready.
Using 1600 ohms coils from 24VDC relays.
A simple test demonstrate that 3 milliamps from the Arduino’s logic pins will be enough to move the compass needle.
This is the Sketch used (the one shown in YouTube is incorrect):
/* CompassStepper Arduining.com 04 MAR 2012 Driving 4 electromagnets arranged arround a compass to produce angular movements of the needle. */ #define COIL11 11 // Terminal 1 of the Coil 1 #define COIL12 10 // Terminal 2 of the Coil 1 #define COIL21 9 // Terminal 1 of the Coil 2 #define COIL22 8 // Terminal 2 of the Coil 2 #define COIL31 5 // Terminal 1 of the Coil 3 #define COIL32 4 // Terminal 2 of the Coil 3 #define COIL41 3 // Terminal 1 of the Coil 4 #define COIL42 2 // Terminal 2 of the Coil 4 #define STEPTIME 1000 void setup(){ // Digital pins 2~11 as outputs. for(int i=2;i<12;i++){ pinMode(i,OUTPUT); digitalWrite(i,LOW); //all coils OFF. } } void loop(){ digitalWrite(COIL11,HIGH); //Turn ON Coil 1 digitalWrite(COIL41,LOW); //Turn OFF Coil 4 delay(STEPTIME); digitalWrite(COIL21,HIGH); //Turn ON Coil 2 digitalWrite(COIL11,LOW); //Turn OFF Coil 1 delay(STEPTIME); digitalWrite(COIL31,HIGH); //Turn ON Coil 3 digitalWrite(COIL21,LOW); //Turn OFF Coil 2 delay(STEPTIME); digitalWrite(COIL41,HIGH); //Turn ON Coil 4 digitalWrite(COIL31,LOW); //Turn OFF Coil 3 delay(STEPTIME); }
Related videos in YouTube:
See the video of how was made:
I need the code for this video you posted,
Please….Please………Thank you
antonio_lopez949@yahoo.com
Code sent and posted!
Thank you for the code.