Aquaponic Gardening

A Community and Forum For Aquaponic Gardeners

http://youtu.be/MY7LnEpYKGw

I wanted to give a run down of the parts used to create the fish feeder.

Parts list:

  1. Arduino UNO
  2. Arduino motor shield
  3. mercury motor sm-42byg011-25
  4. 9v power cord (Radio Shack)
  5. project case to hold motor and Ardiono boards (Radio Shack)
  6. 3/4 augur
  7. 3/4 PVC
  8. Gallon water jug (arrowhead)

Code used to program the Arduino (FYI: anything after // are comments that are ignored by the program language, in case you didn't know) :

// Include the Stepper Library
#include <Stepper.h>
#include <Time.h>
#include <TimeAlarms.h>

// Map our pins to constants to make things easier to keep track of
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;

// 200 is the amount of steps for a full revolution of the motor - I had to play with this to find out.
const int STEPS = 200;
const int mtrSpeedSlow = 30 ;
const int mtrSpeedFast = 60 ;

// Initialize the Stepper class
Stepper myStepper(STEPS, dirA, dirB);

void setup() {
//--------------------------------------
//timer settings....
//--------------------------------------
//set the time when power is applied
setTime(12,00,40,1,1,13); // set time to 12:00:40pm Jan 1 2013

Alarm.alarmRepeat(7,30,0, FeedTime); // 7:30am every day
Alarm.alarmRepeat(12,018,0,FeedTime); // 12:18pm every day
Alarm.alarmRepeat(16,45,0,FeedTime); // 4:45pm every day

// not using, but used for testing.....


// Alarm.timerRepeat(30, RepeatTask); // every 30 seconds
// Alarm.timerRepeat(15, RepeatTaskII); // every 15 seconds
// Alarm.timerOnce(10, OnceOnlyTask); // called once after 10 seconds

//--------------------------------------
// motor settings....
//--------------------------------------
// Set the RPM of the motor to 30
myStepper.setSpeed(mtrSpeedSlow);


// Turn on pulse width modulation
pinMode(pwmA, OUTPUT);
digitalWrite(pwmA, HIGH);
pinMode(pwmB, OUTPUT);
digitalWrite(pwmB, HIGH);

// Turn off the brakes
pinMode(brakeA, OUTPUT);
digitalWrite(brakeA, LOW);
pinMode(brakeB, OUTPUT);
digitalWrite(brakeB, LOW);

// Log some shit
Serial.begin(9600);
}


void loop()
{
// call the full rotation of the motor
Alarm.delay(1000); // wait one second between clock display
}

//--------------------------------------
// Feeding time - 3 full rotations
//--------------------------------------
void FeedTime()
{
// three full rotations...
Serial.println("Feeding Time");
RotateFullRotationCCW();
RotateFullRotationCCW();
RotateFullRotationCCW();

}
void RepeatTask()
{
Serial.println("15 second timer");
RotateFullRotationCCW();
//delay(2000);
RotateFullRotationCCW();
//delay(2000);
RotateFullRotationCCW();
//delay(2000);
}
void RepeatTaskII()
{
Serial.println("15 second timer");
RotateFullRotationCW();
}

//void OnceOnlyTask()
//{
// Serial.println("This timer only triggers once");
// RotateFullRotationCW();
//}

//--------------------------------------
// Clockwise rotations
//--------------------------------------
void RotateFullRotationCW()
{
// Move the motor X amount of steps clockwise
myStepper.step(-STEPS);
Serial.println(-STEPS);
// Pause
// delay(2000);
// delay(50);
}

//--------------------------------------
// Counter Clockwise rotations
//--------------------------------------
void RotateFullRotationCCW()
{
// Move the motor X amount of steps counter clockwise
myStepper.step(STEPS);
Serial.println(STEPS);
// Pause
//delay(2000);
}

Views: 383

© 2024   Created by Sylvia Bernstein.   Powered by

Badges  |  Report an Issue  |  Terms of Service