Devices & Components
Arduino Uno Rev3
USB-A to Mini-USB Cable
Jumper wires (generic)
Laser Diode, 655 nm
IR proximity sensor
DC motor (generic)
Battery, 9 V
Hardware & Tools
Solder Wire, Lead Free
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
RPM_counter_101
arduino
This is the code for the RPM counter.
1//code by YaSh. 2 3int sen = A0; 4const float wid = 0.012; //adjust the width of the fan blade according to your needs. 5const float rad = 0.045; //adjust the radius of the point of detection in the fan blade. 6const float konst = 6.2832; // 2*pi. 7float time_1; 8float time_2; 9float vel; 10float diff; 11float tnet; 12float rpm; 13void setup() 14{ 15 Serial.begin(9600); 16 pinMode(sen,INPUT); 17 Serial.print(" \ 18 please start the motor at least 3 seconds prior.\ 19"); 20 delay(3000); 21} 22void loop() 23{ 24 if(analogRead(sen)<950) 25 { 26 time_1 = millis(); 27 delay(30); 28 } 29 if(analogRead(sen)>950) 30 { 31 time_2 = millis(); 32 diff = (time_2-time_1); 33 vel = wid/diff; //rotation velocity 34 tnet = (konst*rad)/vel; //time = (2*pi*radius)/velocity. 35 rpm = (60000)/tnet; // time in ms to minutes and then to rpm conversion step. 36 } 37Serial.print("\ 38 The rpm is : "); 39Serial.println( rpm ); 40}
RPM_counter_101
arduino
This is the code for the RPM counter.
1//code by YaSh. 2 3int sen = A0; 4const float wid = 0.012; //adjust the width of the fan blade according to your needs. 5const float rad = 0.045; //adjust the radius of the point of detection in the fan blade. 6const float konst = 6.2832; // 2*pi. 7float time_1; 8float time_2; 9float vel; 10float diff; 11float tnet; 12float rpm; 13void setup() 14{ 15 Serial.begin(9600); 16 pinMode(sen,INPUT); 17 Serial.print(" \ 18 please start the motor at least 3 seconds prior.\ 19"); 20 delay(3000); 21} 22void loop() 23{ 24 if(analogRead(sen)<950) 25 { 26 time_1 = millis(); 27 delay(30); 28 } 29 if(analogRead(sen)>950) 30 { 31 time_2 = millis(); 32 diff = (time_2-time_1); 33 vel = wid/diff; //rotation velocity 34 tnet = (konst*rad)/vel; //time = (2*pi*radius)/velocity. 35 rpm = (60000)/tnet; // time in ms to minutes and then to rpm conversion step. 36 } 37Serial.print("\ 38 The rpm is : "); 39Serial.println( rpm ); 40}
Downloadable files
Circuit Schematics
schematic for connecting sensor to the arduino board
Circuit Schematics

Circuit Schematics
schematic for connecting sensor to the arduino board
Circuit Schematics

Setup image.
this is the image for the base and other components placement
Setup image.

Comments
Only logged in users can leave comments