Project : Fish feeder with Arduino Deek-Robot pro mini ATmega 328

Idea comes from :

http://www.instructables.com/id/Arduino-Fish-Feeder

and my work :

Arduino deek-Robot pro mini ATmega328

http://www.xtremxpert.com/index.php/electronique-libre/arduino/25-programmer-un-arduino-mini-pro-deek-robot

A counterfeit Deek Robot Pro Mini from the backside.

https://arduino-board.com/pages/arduino-knockoffs

https://arduino-board.com/boards/dr-pro-mini

 

Download sketch to arduino Deek-Robot pro mini from arduino uno

Initial problem comes from difficulties to download sketch directly from PC/scratch to arduino pro mini : no USB to serial driver available for my PC.

Solution consists in using arduino uno as a downloader

IMPORTANT : select Arduino as ISP. See below :

sketchup

Select the righ card :

CardType

wiring

Picture of Wiring and Programing!

The servo motor

http://www.servodatabase.com/servo/towerpro/sg90

TowerPro SG90

data sheet : http://www.micropik.com/PDF/SG90Servo.pdf

servomotor

Reducing voltage from 9V to 5V

As a reminder only : not used (5V charger used instead)

Typically a LM7805 is used (or LM2940)

http://cdn.instructables.com/FR4/U6VM/FM68F9BA/FR4U6VMFM68F9BA.LARGE.gif

The 7805 needs 7V minimum and the 2940 can work from 5.5V
They can both handle upto a 35V input.

Use a LDO regulator like the LM1117T, LM2931, or equiv. The cheaper 7805 or 78L05 will work, but you won’t get the full capacity out of the battery. If you plan on doing much experimenting it would be better to get a power supply, even a wall wart, instead of the typically weak 9V battery (http://www.electro-tech-online.com/threads/reduce-a-9v-to-5v.98143/)

See if you can get hold of an old car charger for a mobile phone that has an output of about 5V. You should be able to change one resistor to get exactly 5V. This saves having to source all the chokes etc.

Source code

//
// thierry.gaillot@orange.com
// 2015, october 4th
// inspired from : http://www.instructables.com/id/Arduino-Fish-Feeder/
// see : http://mesnotes.apps-1and1.net/
// important note regarding deek-robot pro mini : press reset button and release when RX starts blinking !
//

#include <Servo.h> 
 
Servo myservo; // create servo object to control a servo 
 // a maximum of eight servo objects can be created 
 
int pos = 0; // variable to store the servo position 

//long FISHFEEDER = 43200000; // 12 hours between feeding
long FISHFEEDER = 20; // 12 hours between feeding
long endtime; 
long now;

void blink_led() {
 digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second
 digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
}

void release() {
 // release the servo to shut down noise ...
 myservo.detach();
 //digitalWrite(9, LOW);
 delay(15);
}

void setup() {
 myservo.attach(9); // attaches the servo on pin 9 to the servo object 
 myservo.write(0); // move to initial position
 pinMode(13, OUTPUT); //led confims loop is looping !
 delay(15); // wait a moment before going further
 blink_led(); // just for fun
}

void loop() {
 release();
 
 now = millis();
 endtime = now + FISHFEEDER;
 
 while(now < endtime) { // wait until endtime arrives ...
 delay(9000); // 20000 -> 9000 wait for 20 s before continue loop
 now = millis(); // get time
 blink_led();
 
 // place to test if button pressed, 
 // ie : if we want to feed the fish now

 } // end loop : waiting for 12 hours
 
 // loop is finished : it is time to feed the fish !
 move();

} // end loop

void move() {
 
 setup(); // attach motor only when needed (it makes noise)
 
 // one way
 for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees 
 { // in steps of 1 degree 
 myservo.write(pos); // tell servo to go to position in variable 'pos' 
 delay(15); // waits 15ms for the servo to reach the position 
 } 
 
 // back way
 for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees 
 { 
 myservo.write(pos); // tell servo to go to position in variable 'pos' 
 delay(15); // waits 15ms for the servo to reach the position 
 } 
 myservo.write(0); // origin
 release(); // detach motor
 
} // end move

// end program

Learn more

http://www.mon-club-elec.fr/pmwiki_reference_arduino/pmwiki.php?n=Main.DebuterInstallation

 

Laisser un commentaire