1. S1400430 Sean David Fackrell CT4013 A1
Page 1 of 19
CT4013
Introduction to Physical Computing
and Programming
Assignment1 2014-15
Student Name and ID:
Sean Fackrell s1400430
Date: 02/01/2015
2. S1400430 Sean David Fackrell CT4013 A1
Page 2 of 19
Contents
Figures .......................................................................................................................................2
1. Introduction ............................................................................................................................ 3
2. Personal Project Requirements............................................................................................. 3
3: Reflection and Discussion.....................................................................................................4
3.1: Interesting concepts/techniques learnt. ..........................................................................4
3.2: Technical problems and debugging techniques............................................................. 6
4. Project Testing. .................................................................................................................. 8
5. Video Presentation................................................................................................................. 9
6. References............................................................................................................................. 9
8: Appendix: Software Code Used. ......................................................................................... 10
8.1: Bird Feeder, Non-working code:................................................................................. 10
8.1a: Bird Feeder, Testing of v1.0: ..................................................................................... 11
8.2: Bird Feeder, Working via Push Switch code: ............................................................. 12
8.2a: Bird Feeder, Testing of v1.1: ...................................................................................... 13
8.3: Bird Feeder, Push Switch & Bluetooth code: ............................................................. 14
8.3a: Bird Feeder, Testing of v1.2: ...................................................................................... 16
8.4a: MIT App Inventor ‘blocks’............................................................................................ 17
8.4b: Bluetooth App Screenshot.......................................................................................... 18
8.5: ‘Birduino’ Concept sketch. ........................................................................................... 19
Figures
Figure 1: AutoCAD Feeder Parts Design & Laser cut Parts..................................................... 5
Figure 2: MIT App Inventor and resulting Android App............................................................. 6
Figure 3: RTC Error during testing. ........................................................................................... 6
Figure 4: Assembled Feeder. ....................................................................................................7
3. S1400430 Sean David Fackrell CT4013 A1
Page 3 of 19
1. Introduction
This assignment will be covering the personal project development for the CT4013 Physical
computing and Programming assignment. After some initial pen sketches and research on
the internet, the project to be developed for the assignment is an automatic bird feeder as it
was found there are plenty of feeders for other pets but not specifically for birds.
Throughout there will be reflection on the learning experience, detail of the major technical
problems encountered, the issues found to be the most difficult to resolve, the most
interesting things discovered during the development, and the things that were found to be
the easiest to understand during the development and implementation process of the
project.
2. Personal ProjectRequirements
The electronic bird feeder to be developed as the personal project for the CT4013 module
has a number of specific requirements to make a robust product suitable for use in the
home, and these are:
R1: The solution shall be able to dispense a set amount of bird food pellets at a certain
time each day.
R2: The solution shall be able to store enough food pellets for at least 3 days without
having to be re-filled.
R3: The solution shall be able to dispense additional food pellets as required with
minimal intervention.
R4: The solution shall have as little noise as possible while dispensing so as not to
startle the birds in the feeding process.
R5: The solution shall be scalable, if we needed to dispense more in one go then only
minor modifications are required to either the physical solution or the code running it.
R6: The solution shall be portable and able to operate from a battery if required.
R7: The solution shall be small enough to attach to a birdcage with the minimal of fuss.
R8: The solution shall be able to maintain its own time in memory even if the Arduino
has no power.
R9: The solution shall be small enough to fit all the circuitry inside a small enclosure.
Reflecting on the specific requirements for the solution to be implemented and after some
background research, the components chosen to base the project around were:
1. Arduino Mega (for the additional hardware serial ports)
2. A 12C Real Time Clock (RTC) breakout board by Tiny, type DS1307.
3. A HC-06 Wireless Bluetooth Transceiver module.
4. Arduino project box (provided with the kit)
5. 9v Battery and connector.
6. A spare birdseed dispenser that happened be lying around
7. A single FS90 Micro-Servo as used in model aircraft.
8. Perspex parts cut on the University of Gloucestershire (UoG) laser cutter.
4. S1400430 Sean David Fackrell CT4013 A1
Page 4 of 19
External feeding for this project is intended to be enabled by using an app on an Android™
smartphone or other device via a Bluetooth connection to the feeder with options to add
capability to feed by either sending an email or tweet to the feeder at a later date.
3: Reflection and Discussion.
Prior to starting this module, I was initially quite apprehensive as I did feel that my coding
knowledge would be sorely inadequate despite buying my Arduino kit many months prior to
starting University and starting to work through the example exercises in the accompanying
booklet (Banzi, 2011). I was fully aware that there would be students much more capable
than myself in the module who had studied programming for years. I decided not to dwell on
this fact, concentrate on my own work, and try my very best with the sole aim of passing the
module.
It transpired after starting lectures, that even though I had not done any formal programming
for over 20 years, I quickly realised that there were many others in the lecture group in a
similar situation having little or no prior physical computing experience. Moreover, I quickly
started to recall the programming basics again even though it was a computer language that
was unfamiliar. This combination of lectures, Ambikesh’s lecturing style, homework
challenges, hands on laboratory exercises and free reign to design and develop a project of
personal interest really did help to enhance my learning experience and allay my initial fears
about my ability.
I was truly elated once my project was working because after a lot of heartache with the
code, I had managed to design something of practical use from scratch albeit just a
prototype, this only encouraged me to develop this project further than just completing it to
pass the module.
3.1: Interesting concepts/techniques learnt.
One of the most valuable lessons learnt from designing this project was component selection
and fitness for use. Initially it had been decided to use a stepper motor for dispensing the
food but this was found to be a lot noisier in operation than the micro servo during initial
testing. In addition, it was a lot larger and heavier compared to the micro servo making it
much more difficult to make a small form factor feeder, but it would be ideally suited to a
much large project.
Another interesting technique learnt through the development of the bird feeder project after
speaking to the product design lab was the need to generate 2D Computer Aided Design
(CAD) drawings in a specific DWG file format. This would enable the Perspex pieces for the
bird feeder to be cut using the University laser cutter. Using AutoCAD 2015 Student Edition
by Autodesk (Autodesk Incorporated, 2014) enabled development work for these parts at
home, a rapid learning process in itself as the software had to be learnt from scratch, which
was a little frustrating at times. However, the experience was very enjoyable never the less.
Once the pieces were drafted in CAD and the additional ‘off the shelf’, components were
ordered, authoring of the code started for the project. The most interesting aspect of this part
of the project was that a lot of the code needed to interface with the electrical components
used was either in the public domain, on the Arduino website (Arduino.cc, 2014), or readily
available in the libraries built into the Arduino IDE software.
5. S1400430 Sean David Fackrell CT4013 A1
Page 5 of 19
This enabled the first draft of the code to be composed quite quickly. Combining this with the
wealth of knowledge available in some of the Arduino reference books such as The Arduino
Cookbook (Margoils, 2012), Arduino Projects for Dummies (Craft, 2013) and Getting Started
with Arduino (Banzi, 2011), enabled quick satisfaction that a robust and functional product
should be able to be developed.
Figure 1: AutoCAD Feeder Parts Design & Laser cut Parts
In addition to this, it was found that the layout of the standard Arduino software was a bit
confusing. To enable better understanding of the code the student version of Microsoft
Visual Studio (Microsoft, 2014) was downloaded and used as after initial testing it was found
the additional Arduino plug-in for Visual Studio helped highlight the coding issues due to the
enhanced coloured layout, text prompts and configurable user environment.
Throughout all the lab exercises undertaken and personal project development, the main
concepts understood are common to all computer code no matter whether it is C++, Java or
UNIX and these are the programming concepts of sequence, selection and iteration. This
plus the realisation that you can create a function within the ‘void setup’ code and call that
function within the program loop without having to go to the trouble of having to code it all
over again really helped with the understanding of the language and the aims for the project.
In addition to having to learn how to use CAD to enable the Perspex parts to be cut, It was
also decided to build a custom Android™ app to control the project as the available
marketplace apps for Bluetooth control were just too fiddly. For ease of use, It was decided
to author a one-page app from which you can find and connect to available Bluetooth
devices, and control them. The app was built using the MIT app Inventor (Technology, 2014)
that is available free to all online. This learning experience was particularly interesting as it
involved the building of an app through the use of ‘blocks’ of code and anybody who is
remotely interested in learning the basics of programming should make this part of their
learning experience. Moreover, during the authoring of the app, the additional facilities to
6. S1400430 Sean David Fackrell CT4013 A1
Page 6 of 19
enable E-mail and Twitter communication in the future were included but not activated at this
time, as the hardware was unavailable to test its function.
The Twitter account configuration has to be left empty in the code blocks until development
of the physical product has proceeded far enough that all the parts to enable Wi-Fi
communication are available. It is still a bit rough around the edges but it is functional, just
like the feeder project over all. A larger screenshot has been included in Appendix 8.4.
Figure 2: MIT App Inventor and resulting Android App.
3.2: Technical problems and debugging techniques.
Several major and minor technical problems were encountered during the development of
this project, the first of these being with the RTC module purchased from e-bay.
It was found during the initial setup and testing of the RTC module on its own that nonsense
results were being produced on the Arduino serial monitor as shown below:
Figure 3: Real Time Clock Error during testing.
Initially It was felt that a faulty RTC had probably been purchased or perhaps it had been
wired up incorrectly. It was subsequently discovered after a brief investigation that during the
manual soldering of the pins to the RTC board, the iron temperature had been set too high
singeing the board, this had probably cooked the RTC module in the process. Purchasing a
second module and ensuring correct temperature setting of the soldering iron resolved this
issue.
7. S1400430 Sean David Fackrell CT4013 A1
Page 7 of 19
Another Technical issue encountered was getting the communication between the Mega,
Bluetooth breakout and laptop stable, it appeared that on occasion that it would work
flawlessly, and sometimes it would refuse stubbornly to work at all. It was found after a bit of
probing that there was a dry joint on the TX pin for the Bluetooth module, this factory-
soldered joint was re-soldered and no problems were encountered thereafter.
The third technical issue encountered was that the physical part of the project had to ensure
the feeder arm would move in the way it was intended without jamming or spilling food
during movement. It transpired when the feeder was assembled that the components had
been cut fitted almost as planned, and after a minor adjustment in the hole size in the feeder
there was a mere 0.2mm gap that was unexpected, but after testing it was decided that this
will not be any cause for concern. The assembled project can be seen in Figure 4 below:
Figure 4: Assembled Feeder.
To enable debugging of the software prior to assembling the solution, various techniques
were researched and several methods were found, the most advantageous of which was
found on the Arduino.cc website requiring the insertion of snippets of debugging code within
the source code. This required some code to be inserted at the start of the program code,
this is included below:
#define DEBUG //If you comment this line, the DPRINT & DPRINTLN lines are
defined as blank.
#ifdef DEBUG //Macros are usually in all capital letters.
#define DPRINT(...) Serial.print(__VA_ARGS__) //DPRINT is a macro, debug
print
#define DPRINTLN(...) Serial.println(__VA_ARGS__) //DPRINTLN is a macro,
debug print with new line
#else
#define DPRINT(...) //now defines a blank line
#define DPRINTLN(...) //now defines a blank line
#endif
(LarryD, 2014)
So when you use DPRINT of DPRINTLN(“<text>”) in the section of code you are wanting to
monitor, it prints output to the serial monitor enabling you to see what parts of the code are
being executed (or not) and in what sequence. However, even with these debug codes
8. S1400430 Sean David Fackrell CT4013 A1
Page 8 of 19
inserted there were still issues resolving the software and getting the project to work as
expected. After much frustration, the version1.0 software was discarded and custom
software was authored to parallel the evolving product capabilities.
4. Project Testing.
The lecture covering testing was found to be particularly interesting, as at this point in the
module the bird feeder project still was not working successfully. The testing matrices that
we were advised to use were taken and applied to each of the code versions written to
ensure a robust product that is working according to the specified product requirements.
Attached below is the testing matrix for the Bluetooth version (v1.2) of the project, other
testing matrices are included in the appendix along with the code they were drafted to test.
Req
Id
Type
Test Case
Description
Expected
outcome
Actual
outcome
Result
Severity (critical
or major or
minor or gui)
Reproduci
bility
R1
Positive
test case
Dispensing of set
amount of food
at a designated
time
Arm will
dispense at a
designated
time
No Function
as no RTC
fitted
Fail Major N/A
R1
Negative
test case
No food
dispensedat set
time
error message
No Function
as no RTC
Fail Major N/A
R2
Positive
test case
Adequate
storage for at
least 3 days’
worth of food
Adequate
Storage
Enough
Storage for 1
week
Pass
Reproduc
ible
R3
Positive
test case
Feeder able to
dispense on
demandvia
Bluetooth
Dispense food
one cycle then
stop
Dispenses one
measure of
food then
waits
Pass
Reproduci
ble
R4
Positive
test case
Minimal noise
generated
during operation
Quiet
operation
Minimal noise Pass
Reproduc
ible
R5
Positive
test case
Scalable
solution, more
pieces can be
added to
increase feed
portion.
Additional arm
parts canbe
added to
increase feed
portion.
Possible to
add more
parts.
Pass
Reproduc
ible
R6
Solution
must be
portable
Solutionmust be
portable
Small enough
to be portable
Form factor
acceptable
Pass
Reproduc
ible
R6
Positive
test case
Solutionshould
be able to be
batterypowered
Batterypower
sufficient for
3+ days
Batterylasted
> 3 days
Pass
New batteryused
in this testing
Reproduci
ble
R7
Positive
test case
Attach to cage
with minimal
fuss
Easyto fit
Easyto fit to
cage
Pass
Reproduc
ible
R8
Positive
test case
Solutionshould
be able to
maintaintime in
memoryevenif
powered off
Time should be
up to date in
serial monitor
No Function
as no RTC
fitted
Fail
No RTCfitted in
this version
N/A
R9
Positive
test case
Should be small
enoughto fit in
a small
enclosure
No wires or
circuitry
showing
Top of
enclosure
cannot be
fitted properly
Fail
Minor, newcasing
needs to be
acquired or made
9. S1400430 Sean David Fackrell CT4013 A1
Page 9 of 19
In conclusion, a robust functional product was developed from scratch this included the
physical product, the Perspex parts required to make it work as planned, the code to operate
the product and the custom Bluetooth app for Android™ devices.
Identification of product requirements and an established testing matrix enabled identification
and swift rectification of programming errors in the code. Although the current working
version (v1.2) does not enable feeding via timed dispense as yet, this will be added in further
project development and additional functionality will be added in the future such as feeding
via Twitter and E-mail.
5. Video Presentation
Below I attach the hyperlink to my You-Tube Presentations:
Project Demo: http://youtu.be/sj_7bb8imOo
Coursework summary: http://youtu.be/dxHuGbJzOss
6. References
Arduino.cc,2014. Arduino. Availableat:http://playground.arduino.cc/
[Accessed14 October2014].
AutodeskIncorporated,2014. Autodesk.com. Availableat:
http://www.autodesk.com/education/free-software/autocad#
[Accessed22 October2014].
Banzi,M., 2011. Getting Started With Arduino. 2nded.Cambridge:O'Reilly.
Craft,B., 2013. Arduino Projectsfro Dummies. Chichester(WestSussex):JohnWiley&SonsLtd..
LarryD, 2014. Arduino Forums(Howto debug codein Arduino IDE). Available at:
http://forum.arduino.cc/index.php?topic=215334.0
Margoils,M., 2012. Arduino Cookbook. Cambridge:O'ReillyPublishing.
Microsoft,2014. VisualStudio. Available at:http://www.visualstudio.com/
[Accessed22 October2014].
Technology,M.I. T., 2014. MIT App Inventor. Availableat:http://appinventor.mit.edu/explore/
[Accessed6December2014].
10. S1400430 Sean David Fackrell CT4013 A1
Page 10 of 19
8: Appendix: SoftwareCode Used.
8.1: Bird Feeder, Non-working code:
//========================================//
// Author: Sean David Fackrell //
// December 2014 v1.0 //
// CT 4013 Assignment 1 Project //
// Project Title: Electronic Bird Feeder //
// Bluetooth and RTC (Non-Working) //
//========================================//
#include <Servo.h>
#include <Wire.h>
const byte DS1307_CTRL_ID = 0x68; // address of the DS1307 real-time clock
const byte constNumberOfFields = 3; // the number of fields (bytes) to request from
// the RTC
const byte constServoSignalPin = 9; // Servo connected to Digital 9
const byte constTimeToFeed = 9 * 60; // 9:00 am
byte Second;
byte Minute;
byte Hour;
byte currentTime;
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the initial servo position
void setup(){Serial.begin(9600);
Wire.begin();}
byte bcd2dec(byte num){return ((num / 16 * 10) + (num % 16));
// Convert Binary Coded Decimal (BCD) to Decimal
}
int getTime(){
Wire.beginTransmission(DS1307_CTRL_ID);
Wire.write((uint8_t)0x00);
Wire.endTransmission();
Wire.requestFrom(DS1307_CTRL_ID, constNumberOfFields);
Second = bcd2dec(Wire.read()); // (0-59)
Minute = bcd2dec(Wire.read()); // (0-59)
Hour = bcd2dec(Wire.read()); //assumes 24hr clock (0-23)
}
void OpenFeeder(){
myservo.attach(constServoSignalPin); // attaches the servo on pin 9 to the
for (pos = 57; pos <= 28; pos += 1) // servo object
{myservo.write(pos); // tell servo to go to position in variable 'angle'
delay(5000);} // wait 5 seconds
for (pos = 28; pos >= 57; pos += 1)
{myservo.write(pos); // tell servo to go to position in variable 'angle'
delay(5000); // delay in ms
myservo.detach();}} // remove the servo to save power.
void printDigits(int digits) // utility function for clock
{Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);}
void digitalClockDisplay(){ // digital clock display of the time
Serial.print(Hour);
printDigits(Minute);
printDigits(Second);
Serial.println();}
void loop(){ currentTime == getTime(); //if (BirdShoudlBeFed)
if (currentTime == constTimeToFeed)
OpenFeeder();
digitalClockDisplay();}
11. S1400430 Sean David Fackrell CT4013 A1
Page 11 of 19
8.1a: Bird Feeder, Testing of v1.0:
Req
Id
Type Test Case
Description
Expected
outcome
Actual
outcome
Result Severity
(critical
or major
or minor
or gui)
Reprodu
cibility
R1 Positive
test
case
Dispensing of set
amount of food at a
designated time
Arm will
dispense 1
measured
amount at
a
designated
time
Hardware
loop,
constantly
running
Fail Major
R1 Negative
test
case
No food dispensed at
set time
error
message
Hardware
loop,
constantly
running
Fail Major
R2 Positive
test
case
Adequate storage for
at least 3 days’ worth
of food
Adequate
Storage
Enough
Storage for
1 week
Pass Reprodu
cible
R3 Positive
test
case
Feeder able to
dispense on demand
Dispense
food one
cycle then
stop
Hardware
loop,
constantly
running
Fail Major
R4 Positive
test
case
Minimal noise
generated during
operation
Quiet
operation
Minimal
noise
Pass Reprodu
cible
R5 Positive
test
case
Saleable solution,
more pieces can be
added to increase
feed portion.
additional
parts ca be
added
Possible to
add more
parts
Pass Reprodu
cible
R6 Positive
test
case
Solution must be
portable
Small
enough to
be portable
Form factor
acceptable
Pass Reprodu
cible
R6 Positive
test
case
Solution should be
able to be battery
powered
Battery
power
sufficient for
1 week
Battery
lasted 3
days
Fail Minor,
due to
excessive
testing.
R7 Positive
test
case
Attach to cage with
minimal fuss
Easy to fit Easy to fit
to cage
Pass Reprodu
cible
R8 Positive
test
case
Solution should be
able to maintain time
in memory even if
powered off
time should
be up to
date in
serial
monitor
Time kept
up to date
Pass Reprodu
cible
R9 Positive
test
case
should be small
enough to fit in a
small enclosure
no wires or
circuitry
showing
Top cannot
be fitted
Fail Minor,
new
casing
needs to
be
acquired.
12. S1400430 Sean David Fackrell CT4013 A1
Page 12 of 19
8.2: Bird Feeder, Working via Push Switch code:
//========================================//
// Author: Sean David Fackrell //
// December 2014 v1.1 //
// CT 4013 Assignment 1 Project //
// Project Title: Electronic Bird Feeder. //
// Physical Switch //
//========================================//
#define DEBUG //If you comment this line, the DPRINT & DPRINTLN lines are defined as
blank.
#ifdef DEBUG //Macros are usually in all capital letters.
#define DPRINT(...) Serial.print(__VA_ARGS__) //DPRINT is a macro, debug print
#define DPRINTLN(...) Serial.println(__VA_ARGS__) //DPRINTLN is a macro, debug print
with new line
#else
#define DPRINT(...) //now defines a blank line
#define DPRINTLN(...) //now defines a blank line
#endif
#include <Servo.h> // includes servo library
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int feedpin = 14; // Sets push pin connection to digital 14
//end of Configuration code.
void setup()
{pinMode(feedpin, INPUT); //Sets digital 14 push button as an input.//
digitalWrite (feedpin, LOW);} // attaches the servo on pin 9 to the servo object
//End of Setup Code
void activatefeeder(){ // this is the code to cycle the feeder.
myservo.attach(9); //Attaches Servo to Arduino.
for(pos = 27; pos <=65; pos +=1) // goes from 27 degrees to 65degrees in steps of 1
degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(5000); // waits 15ms for the servo to reach the position
for(pos = 65; pos>=27; pos-=1) // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(500); //Waits 1 second for it to reach this position
myservo.detach();} //Detaches Servo From Arduino to save Power
// End of main program body.
void loop(){
int state = digitalRead (feedpin); //looks at the State of Pin 14
if (state == HIGH) // if there is voltage on pin 14
activatefeeder();} // this cycles the Feeder.
// end of program loop
13. S1400430 Sean David Fackrell CT4013 A1
Page 13 of 19
8.2a: Bird Feeder, Testing of v1.1:
Req
Id
Type Test Case
Description
Expected
outcome
Actual
outcome
Result Severity (critical
or major or
minor or gui)
Reproduci
bility
R1 Positive
test case
Dispensingof
set amount of
food at a
designated
time
Arm will
dispense1
measured
amount ata
designated
time
No Function
as no RTC
fitted
Fail Major
N/A
R1 Negative
test case
No food
dispensed at
set time
error
message
No Function
as no RTC
Fail Major
N/A
R2 Positive
test case
Adequate
storage for at
least3 days’
worth of food
Adequate
Storage
Enough
Storage for 1
week
Pass
Reproduc
ible
R3 Positive
test case
Feeder ableto
dispenseon
demand via
pressing
physical switch
Dispense
food one
cyclethen
stop
Dispenses
one measure
of food then
waits
Pass
Reproduci
ble
R4 Positive
test case
Minimal noise
generated
during
operation
Quiet
operation
Minimal
noise
Pass
Reproduc
ible
R5 Positive
test case
Scalable
solution,more
pieces can be
added to
increasefeed
portion.
Additional
parts can be
added to
increasefeed
portion.
Possibleto
add more
parts
Pass
Reproduc
ible
R6 Solution
must be
portable
solution must
be portable
Small enough
to be
portable
Form factor
acceptable
Pass
Reproduc
ible
R6 Positive
test case
Solution
should be able
to be battery
powered
Battery
power
sufficientfor
3+ days
battery
lasted +3
days
Pass New battery used
in this testing Reproduci
ble
R7 Positive
test case
Attach to cage
with minimal
fuss
Easy to fit Easy to fitto
cage
Pass
Reproduc
ible
R8 Positive
test case
Solution
should be able
to maintain
time in
memory even
if powered off
Time should
be up to date
in serial
monitor
No Function
as no RTC
fitted
Fail No RTC fitted in
this version
N/A
R9 Positive
testcase
Shouldbe
small enough
to fitina
small
enclosure
No wiresor
circuitry
showing
Top of
enclosure
cannot be
fitted
properly
Fail Minor,new
casingneedsto
be acquiredor
made
14. S1400430 Sean David Fackrell CT4013 A1
Page 14 of 19
8.3: Bird Feeder, Push Switch & Bluetooth code:
//========================================//
// Author: Sean David Fackrell //
// December 2014 v1.2 //
// CT 4013 Assignment 1 Project //
// Project Title: Electronic Bird Feeder //
// Physical Switch & Bluetooth //
//========================================//
#define DEBUG //If you comment this line, the DPRINT & DPRINTLN lines are
defined as blank.
#ifdef DEBUG //Macros are usually in all capital letters.
#define DPRINT(...) Serial.print(__VA_ARGS__) //DPRINT is a macro, debug
print
#define DPRINTLN(...) Serial.println(__VA_ARGS__) //DPRINTLN is a macro,
debug print with new line
#else
#define DPRINT(...) //now defines a blank line
#define DPRINTLN(...) //now defines a blank line
#endif
#include <Servo.h> // includes servo library
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int feedpin = 14; // Sets the Physical button pin to Digital 14
void setup(){
pinMode(feedpin, INPUT); // physical switch is an input
digitalWrite(feedpin, LOW); // Sets Default state of Digital 14 to LOW
Serial.begin(9600); // starts serial port
int state = digitalRead(feedpin); // Looks at Digital pin 14 to check the state (High or
Low)
if (state == HIGH); // if it is high
bluefeed(); // Arduino runs Bluefeed Function.
}
void loop() // this is the program loop
{
if (Serial.available() > 0) //Checks to see if there is greater than 0 ports available
{
int feed = Serial.read(); // Listens to the serial port for input
switch (feed ) // To see if feed is triggered
{case 'Y': // IF Serial monitor receives an upper case Y
bluefeed(); // Arduino Runs the bluefeed Function
case 'y': // IF Serial monitor receives an lower case y
bluefeed() // Arduino Runs the bluefeed Function
break; // But stops after 1 cycle until either of the 2 true states are
triggered again.
default: // anything other than y or Y is ignored.
break; }} // But stops after 1 cycle until either of the 2 true states are
triggered again.
delay(500); // It waits a half a second.
serial.println("feed");
} // Then prints "feed" to the Serial monitor to allow debugging.
15. S1400430 Sean David Fackrell CT4013 A1
Page 15 of 19
void bluefeed() // This is the Feeding function.
{myservo.attach(9); // attaches the servo to the Arduino.
for (pos = 27; pos <= 65; pos += 1) // goes from 27 degrees to 65 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(5000); // waits 5seconds for the servo to reach the position
for (pos = 65; pos >= 27; pos -= 1) // goes from 65 degrees to 27 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(1000); // waits 1 second for it to reach this position.
myservo.detach(); // detaches the servo to save power...
}
16. S1400430 Sean David Fackrell CT4013 A1
Page 16 of 19
8.3a: Bird Feeder, Testing of v1.2:
Req
Id
Type Test Case
Description
Expected
outcome
Actual
outcome
Result Severity (critical
or major or
minor or gui)
Reproduci
bility
R1 Positive
test case
Dispensingof
set amount of
food at a
designated
time
Arm will
dispense1
measured
amount ata
designated
time
No Function
as no RTC
fitted
Fail Major
N/A
R1 Negative
test case
No food
dispensed at
set time
error
message
No Function
as no RTC
Fail Major
N/A
R2 Positive
test case
Adequate
storage for at
least3 days’
worth of food
Adequate
Storage
Enough
Storage for 1
week
Pass
Reproduc
ible
R3 Positive
test case
Feeder ableto
dispenseon
demand via
Bluetooth
Dispense
food one
cyclethen
stop
Dispenses
one measure
of food then
waits
Pass
Reproduci
ble
R4 Positive
test case
Minimal noise
generated
during
operation
Quiet
operation
Minimal
noise
Pass
Reproduc
ible
R5 Positive
test case
Scalable
solution,more
pieces can be
added to
increasefeed
portion.
Additional
arm parts can
be added to
increasefeed
portion.
Possibleto
add more
parts.
Pass
Reproduc
ible
R6 Solution
must be
portable
solution must
be portable
Small enough
to be
portable
Form factor
acceptable
Pass
Reproduc
ible
R6 Positive
test case
Solution
should be able
to be battery
powered
Battery
power
sufficientfor
3+ days
battery
lasted 3
+days
Pass New battery used
in this testing Reproduci
ble
R7 Positive
test case
Attach to cage
with minimal
fuss
Easy to fit Easy to fitto
cage
Pass
Reproduc
ible
R8 Positive
test case
Solution
should be able
to maintain
time in
memory even
if powered off
Time should
be up to date
in serial
monitor
No Function
as no RTC
fitted
Fail No RTC fitted in
this version
N/A
R9 Positive
testcase
Shouldbe
small enough
to fitina
small
enclosure
No wiresor
circuitry
showing
Top of
enclosure
cannot be
fitted
properly
Fail Minor,new
casingneedsto
be acquiredor
made
17. S1400430 Sean David Fackrell CT4013 A1
Page 17 of 19
8.4a: MIT App Inventor ‘blocks’
18. S1400430 Sean David Fackrell CT4013 A1
Page 18 of 19
8.4b: Bluetooth App Screenshot.
19. S1400430 Sean David Fackrell CT4013 A1
Page 19 of 19
8.5: ‘Birduino’ Concept sketch.