自動餵魚器
零件的3D檔案下載 (.stl)
PLA列印,噴頭溫度210度C、熱床40度C,列印速度皆為50,內外全部支撐
其他材料
1. Arduino nano
2. Arduino nano sensor shield (擴展版)
3. 28BYJ-48 步進馬達
4. ULN2003 步進馬達驅動器
5. 杜邦線
6. 10K可變電阻 (手動進料開關)
7. M3 10mm螺絲 8個
8. M3六腳螺帽 3個
9. M3 15mm螺絲兩支
10. 9V直流電源供應器
11. 迴紋針(儲料槽蓋的關節用)
程式碼
#include <Stepper.h>
unsigned long sum ,t , hr , mins , sec ;
const int stepsPerRevolution = 2048;
int sethr = 12; //每12小時餵食一次(此處可做調整)
int x[61];
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);
void setup() {
myStepper.setSpeed(10);
Serial.begin(9600);
}
void loop() {
for(int i=0 ; i<60 ; i++){
x[i] = analogRead(A0);
}
sum = 0 ;
for(int i=0 ; i<60 ; i++){
sum = sum + x[i];
}
sum=sum/60 ;
t=millis()/1000;
sec=t%60;
mins=t/60%60;
hr=t/3600;
Serial.print(hr);
Serial.print(" , ");
Serial.print(mins);
Serial.print(" , ");
Serial.println(sec);
if(hr%sethr==0 && mins==0 && sec==10){
myStepper.step(1000);
}
if(sum<200){ //手動啟動步進馬達
myStepper.step(10);
}
}