Arduino – Automatic Fish Feeder

What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

From the previous Arduino - Servo post, we've already learned how to run Servo motor with Arduino.

if not, just click the following button and take a look at the post to see what you can do. 🙂

 

Arduino Servo

 

Once you're ready to go further with Servo motor, now we can start. 🙂

From this post, we're going to make 'Automatic Fish Feeder' using Arduino and Servo.

 

Are you already excited? Let's dive in!

 

How we do (Hardware)

Please see the following diagram carefully and make your own system just like it!

 

How we do (Software)

Let's take a look at Software side.


If anyone does not know 'How to upload our sketch to Arduino', then please click the following article before you go.


HowTo Upload Sketch


 

Once your Arduino is ready, just type the following codes into your Arduino IDE.

 

#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

// 1 second : 1000;
// 1 min : 60000;
// 1 hour : 3600000;
// 6 hours : 21600000;
// 8 hours : 28800000;
// 10 hours : 36000000;
long FISHFEEDER = 28800000;
long endtime;
long now;

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop()
{
now = millis();
endtime = now + FISHFEEDER;

while(now < endtime) {
now = millis();
}

//myservo.attach(9);
//delay(15);

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
}
for(pos = 180; pos>=0; 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(90);
// myservo.detach();
// delay(15);
// myservo.detach();
// delay(15);
}

 

So now you'll be able to see Servo motor only rotates with the factor your time-interval(FISHFEEDER) configured.

If you're not sure it's working or want to check it's working quickly, just change 'FISHFEEDER' to shorter time such as 5000 (5 seconds).

How was it? Have you had lots of fun or already got some better idea to extend this to your own project?

then go for it. 🙂

Still shots Outcome

Please find the attached Still shots and compare with yours!

 

Arduino – Rover


What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

As you can see from the other posts, there are many rover versions you can make.

However, this is only one Rover you can make by using Arduino!

so now you're interested? 🙂

How we do (Hardware)

As you already know, we need both sender and receiver sides.

 

  • Transmitter

 

 

  • Receiver

 

How we do (Software)

Please note that if you buy the kit, you will get Arduino on which all the codes were already uploaded.

so you don't need to do anything. just connect and play.

 

However, if not or you want to follow steps and learn how software parts works, 

please find the enclosed documents or instructions for further details.

 


  • Sneak peek on software part

 

As this is remote version of controlling DC motors(Arduino Car), we need both sender and receiver.

 

  • Sender

Step 1) Include necessary libraries

Step 2) Declare variables for Joystick position and pins we want to use with

Step 3) Implement setup function

Step 4) Implement loop function

Step 4-1) Read Analog values from Joystick

Step 4-2) Map the values into ones which can be used in Car(Motor) control

Step 4-3) Send resultant position values to receiver

 

  • Receiver

Step 1) Include necessary libraries

Step 2) Declare variables for driver and motor control pins

Step 3) Implement setup function

Step 4) Implement loop function

Step 4-1) Check if we received data

Step 4-2) Retrieve joystick positions and calculate them into ones which can be used motor control

Step 4-3) Y-axis used for forward and backward control

Step 4-4) X-axis used for left and right control

Step 4-5) Defines forward , backward and stop functions for controlling motors

 

The full codes are available at the enclosed docs. (Arduino_Rover_HowWeDo_SW.txt)

Still shots Outcome

As you can see from the outcome video, it's pretty cool!.

 

Let's make more interesting things with your great ideas!

 

  • Transmitter side

 

  • Receiver side

 

 

Arduino – Control Servos with Joystick (remote)


What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

We know how to make Servo move with Joystick in previous lessons.

but furthermore, we're going to learn how we can control Servos with Joystick in remote! ?

How we do (Hardware)

As you already know, we need both sender and receiver sides.

 

  • Transmitter

 

 

  • Receiver

 

How we do (Software)

Let's take a look at Software side.

If anyone does not know 'How to upload our sketch to Arduino', then please click the following article before you go.

 

HowTo Upload Sketch  

 

As this is remote version of controlling servos, we need both sender and receiver.

 

  • Sender

Step 1) Include necessary libraries

Step 2) Declare variables for Joystick position and pins we want to use with

Step 3) Implement setup function

Step 4) Implement loop function

Step 4-1)  Read Analog values from Joystick

Step 4-2) Map the values into ones which can be used in Servo position

Step 4-3) Send resultant position values to receiver

 

The full codes are available at RF433Sender_RadioHead_ServoControl.ino

 

  • Receiver

Step 1) Include necessary libraries

Step 2) Declare variables for driver and Servo pins

Step 3) Implement setup function

Step 4) Implement loop function

Step 4-1) Check if we received data

Step 4-2) Retrieve Servo positions and write them into Servo motors

 

The full codes are available at RF433Receiver_RadioHead_ServoControl.ino

Still shots Outcome

As you can see from the outcome still shots, it's pretty cool!.

Let's make more interesting things with your great ideas!

 

Arduino – Control Servos with Joystick



What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

We know how to make Servo move in previous lessons.

but furthermore, we're going to learn how we can control Servos with Joystick! 🙂

How we do (Hardware)

How we do (Software)

Let's take a look at Software side.

If anyone does not know 'How to upload our sketch to Arduino', then please click the following article before you go.

 

HowTo Upload Sketch  

 

Step 1) Include the Servo library for controlling Servo motor

 

#include <Servo.h>

 

Step 2) Declare Servo pins and Joystick pins we want to use with

 

int ServoPin1 = 3; 
int ServoPin2 = 5;
int joyX = 0;
int joyY = 1;
int joyVal;

 

Step 3) Create Servo objects to control  Servos

 

Servo servo1; 
Servo servo2;

 

Step 4) Attach the servo to the 3 and 5 pins

 

void setup() 
{  
servo1.attach(ServoPin1);
servo2.attach(ServoPin2);
}

 

Step 5) Reading analog values from joyX and joyY and mapping them into servo1 and servo2 with 15ms delay.

 

void loop() 
{
joyVal = analogRead(joyX);
joyVal = map(joyVal, 0, 1023, 0, 180);
servo1.write(joyVal);
joyVal = analogRead(joyY);
joyVal = map(joyVal, 0, 1023, 0, 180);
servo2.write(joyVal); delay(15);
}

 

 

Still shots Outcome

As you can see from the outcome video, it's pretty cool!.

Let's make more interesting things with your great ideas!

 

 

Arduino – Servo motor



What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

We're going to learn how to run motor called Servo.

This Post explains how to control a servo from your computer using Arduino. 

 

SG90 is one of most famous server motor when we use servo or learn how it works with Arduino. 

Let's dive in! 🙂

How we do (Hardware)

Please see the following diagram carefully and make your own system just like it!

 

 

please note Servo motor has three wires.

 

They are black, red and yellow coloured wires normally, but some Servo motors have different wire colours.

 

Black(or Brown)-coloured wire should be connected to GND pin of Arduino. (Ground)

 

Red-coloured wire should be connected to 5V pin of Arduino. (Power)

 

Yellow(or Orange)-coloured wire should be connected to 7 pin of Arduino. (Signal)

 

As you can see, we've picked 7 pin to send signal to Arduino.

 

How we do (Software)

Let's take a look at Software side.

 

If anyone does not know 'How to upload our sketch to Arduino', then please click the following article before you go.

 

HowTo Upload Sketch

 


  • Move Servo to various degrees

Step 1) Include the Servo library for controlling Servo motor

#include <Servo.h>

Step 2) Declare Servo pin we want to use with

int ServoPin = 7;

Step 3) Create Servo object to control a Servo

Servo MyServo;

Step 4) Attach the servo to the 7 pin

void setup() 
{  
MyServo.attach(ServoPin);
}

Step 5) Move Servo to 0, 45, 90, 135 and 180 degrees with 1 second delay

void loop() 
{
MyServo.write(0);
delay(1000); // 0 degrees
MyServo.write(45);
delay(1000); // 45 degrees
MyServo.write(90);
delay(1000); // 90 degrees
MyServo.write(135);
delay(1000); // 135 degrees
MyServo.write(180);
delay(1000); // 180 degrees
}


  • Practical Example : waving hand

Step 1) Include the Servo library for controlling Servo motor

#include <Servo.h>

Step 2) Declare Servo pin we want to use with

int ServoPin = 7;

Step 3) Create Servo object to control a Servo

Servo MyServo;

Step 4) Attach the servo to the 7 pin

void setup() 
{  
MyServo.attach(ServoPin);
}

Step 5) We just need to move Servo from 0 to 180 degrees and vice versa with very short delay

so that this action looks like waving hand. 🙂

void loop() 
{
MyServo.write(180);
delay(600);
MyServo.write(0);
delay(600);
}

If you want to see it's moving quicker, use the following code.
void loop()
{
MyServo.write(180);
delay(300);
MyServo.write(0);
delay(300);
}

If you want to adjust the angle of waving hand, use the following code.
void loop()
{
MyServo.write(135);
delay(300);
MyServo.write(45);
delay(300);
}

How was it?
I believe you can be more smart or think about great idea to extend this.
You can do it! 🙂

Still shots Outcome

From this course, we've learned how to set pin for sending signal to Servo, and then we're able to make Servo motor move to 0 to 180 degrees.

Any program can be made by you! It's totally up to you. 🙂

 

Please find the attached Still shots and compare with yours!

 

 

How to upload your sketch to Arduino



Download
Install
Run
Write & Save Code
Connect & Check it
Verify
Download

Please click here Arduino IDE Download to get Arduino IDE.

Install

Install Arduino IDE by running arduino-1.8.5-windows.exe. Once you finish installation, you'll be able to see this symbol from your windows task bar.

Run

Please click Arduino IDE from your task bar to load Arduino IDE window.

Write & Save Code

Please write sample code into it.

File - Save save your sketch to somewhere.

Connect & Check it

 

Verify

Verify button click : compile your sketch

Upload button click : upload your sketch to Arduino Uno

If your Arduino Uno's pin 13 is blinking with 1 second delay, your job is done well!

 

Congratulations!

 

 

Arduino – LED2


 

 


What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

From the previous post (Arduino - LED1), we can easily extend or modify our Blink LED example for further learning. 🙂

However, we should need breadboard for playing with multiple LEDs in this post.

How we do (Hardware)

Please note that I'm not using breadboard when we play with two of LEDs, but you can choose to use it or not.

(I wanted to show you how hard the wiring is without breadboard)

 

In case of using three LEDs, we should definitely use breadboard, otherwise that can be quite messy and hard to wire all of them. 🙂

 

  • Blink Two LEDs with different delay time (blue and red LED together)

  • Blink Three LEDs without delay time

How we do (Software)
  • Blink LED with more delay (more than 1 second)

Step 1) Define pin number. we can use different pin at this time.

 

int ledPin = 10;

 

Step 2) Configure 10 pin as an output.

 

void setup() 
{
pinMode(ledPin, OUTPUT);
}

 

Step 3) Turn ON/OFF LED with delays

 

void loop() 
{
digitalWrite(ledPin, HIGH);
delay(2000);
digitalWrite(ledPin, LOW);
delay(3000);
}

 

Step 4)

You can see LED Light On and then Off after 2 secs, and On again after 3 secs.


  • Blink Two LEDs with different delay time (blue and red LED together)

Step 1) Define pin number. we need to define 2 pins now.

 

int ledPin1 = 10;

int ledPin2 = 12;

 

Step 2) Configure 10 and 12 pin as an output.

 

void setup() 
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}

 

Step 3) Turn ON/OFF LED with delays

 

Now we can configure to turn ON/OFF two LEDs with different delay times.

  1. Turn On LED 1
  2. After 3 secs, turn On LED 2
  3. After 4 secs, turn Off LED 1
  4. After 5 secs, turn Off LED2
  5. this step replays after 6 secs

The above is my plan. you can design your own plan. 🙂

 

void loop() 
{
digitalWrite(ledPin1, HIGH);
delay(3000);
digitalWrite(ledPin2, HIGH);
delay(4000);
digitalWrite(ledPin1, LOW);
delay(5000);
digitalWrite(ledPin2, LOW);
delay(6000);
}

 

Step 4)

Please carefully watch your LEDs to check if they're acting like you want.


  • Blink Three LEDs without delay time

This time, we can try to do more funny one. without delay times!

 

Step 1) Define pin number. we need to define 3 pins now.

 

int ledPin1 = 10;

int ledPin2 = 11;

int ledPin3 = 12;

 

Step 2) Configure 10, 11 and 12 pin as an output.

 

void setup() 
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

 

Step 3) Turn ON/OFF LED without delays

 

Now we can configure to turn ON/OFF three LEDs without any delays.

  1. Turn On LED 1 / 2 / 3 subsequently
  2. Turn Off LED 1 / 2 / 3 subsequently
  3. this step replays after 5 secs

The above is my plan. you can design your own plan. 🙂

 

void loop() 
{
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
delay(5000);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
delay(2000);
}

 

Step 4)

Please carefully watch your LEDs to check if they're acting like you want.

Still shots Outcome

Well done! 🙂

As you can see from the above examples, you can design and develop your own programs with your various good ideas. The more you think, the better program you have!

 

 

 

Arduino – LED




What we do
What we need
How we do (Hardware)
How we do (Software)
Still shots Outcome
What we do

We’re going to learn how to turn On/Off LEDs.

There is a built-in LED in Arduino Uno. Its pin number is #13.  

We can also use another pin for turn ON LEDs and even use breadboard or not.

so we'll cover all these situations. 🙂

What we need

 

 

 

Please note that this kit also includes 'Breadboard' which was not mentioned in this post.

 

However you should need it in the next Arduino LED2 post.

 

With using breadboard, we can set up circuit quite easily and efficiently. You will get to know it soon. 🙂

How we do (Hardware)

Please see the following diagram carefully and make your own system just like it!

 

please note LED has two legs. (long and short)

Long lead is '+' and short one is '-'.

 

 

  • Another example using breadboard

Arduino pin 3 - Ohm

Arduino pin GND - LED (-)

Ohm - LED (+)

How we do (Software)

Now, we're all ready to go in Hardware side.

Let's take a look at Software side then.

First of all, we need to know How to upload our sketch to Arduino.

 

HowTo Upload Sketch

 


  • Blink LED without Breadboard

Step 1) Define the pin number that LED is connected to.  'int' means 'Integer' value.

int ledPin = 13;

Here, we're setting it as '13' pin.

 

Step 2) Configure 13 pin as an output. this means LED's output (ON/OFF).

void setup() 
{
pinMode(ledPin, OUTPUT);
}

 

Step 3) Make LED ON/OFF with sketch's loop function.

 

it's going into loop function again and again just like its name.

digitalWrite function is to give HIGH or LOW to turn LED ON/OFF.

HIGH means ON and LOW means OFF here.

Also we should give them some delay by using delay function.

1000 means 1000 milliseconds, which is 1 second.

 

void loop() 
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

 


  • Blink LED with Breadboard

Now, we can use other pins rather than built-in #13 pin.

Take a look at 'How to do (Hardware)' tab and another example using breadboard.

 

and then type this code into your Arduino IDE.

int ledPin = 3; 

void setup() {

//Initialize the digital pin as an output with pinMode()
pinMode(ledPin, OUTPUT);

}

void loop() {

digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(3000); // wait for 3 seconds
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(3000); // wait for 3 seconds

}
Still shots Outcome

From this course, we've learned how to set pin for LED output, how to turn it ON/OFF and how to give it a delay.

Please look at some still shots and compare what you have done! 🙂