Lecture notes from 21-2-2018

// Operators example for Arduino
// Written by Ted Burke 21-2-2018

// TCRT5000 on D7
// Switch on D8

void setup()
  // Digital output pins to control motors
  pinMode(4, OUTPUT); // White LED
  pinMode(5, OUTPUT); // Green LED
  pinMode(6, OUTPUT); // Blue LED

void loop()
  int a, b;

  a = 1;
  b = 1;

  while (1)
    a = digitalRead(8);
    b = digitalRead(7);
    digitalWrite(4, HIGH); // white on
    digitalWrite(4, LOW); // white off
  // Flash blue LED for 5 seconds
  digitalWrite(6, HIGH);
  digitalWrite(6, LOW);
Posted in Uncategorized | Leave a comment

Example from today’s lecture – RTTW

Here’s the circuit from today’s example:

Here’s that Inkscape tutorial video we looked at:

Here’s the code example we worked on:

// Race to the wall example for Arduino
// Written by Ted Burke 14-2-2018

void setup()
  // Digital output pins to control motors
  pinMode(4, OUTPUT); // LM forward
  pinMode(5, OUTPUT); // LM reverse
  pinMode(6, OUTPUT); // RM forward
  pinMode(7, OUTPUT); // RM reverse

void loop()
  int s;

  // Drive forward while switch not pressed
  s = digitalRead(2);
  while( s == 0 )
    // Both motors forward
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);

    s = digitalRead(2);

  // Both motors reverse
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  digitalWrite(6, LOW);
  digitalWrite(7, HIGH);

  // Black line detected

  // Stop
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);


Screenshot of WordPress editor:

Emma’s Ozobot:

Posted in Uncategorized | Leave a comment

Three colours LED example with TCRT5000 and switch

// Three colours example for Arduino
// Written by Ted Burke 7-2-2018

void setup()
  pinMode(4, OUTPUT); // white LED
  pinMode(5, OUTPUT); // green LED
  pinMode(6, OUTPUT); // blue LED

void loop()
  int x, y;

  x = digitalRead(7);
  if (x == 1)
    digitalWrite(6, HIGH);    
    digitalWrite(6, LOW);

  y = digitalRead(8);

  if (y == 1)
    digitalWrite(5, HIGH); // green LED on
Posted in Uncategorized | Leave a comment

Images from today’s lecture on LED / motor control from Arduino

Link to the datasheet for the SN754410NE driver IC

Information on the Race to the Wall (from last semester – subject to change)

Posted in Uncategorized | Leave a comment

Welcome to RoboSumo – Semester 2, 2017-2018

Welcome to the RoboSumo project, which is undertaken by students of programme DT066A (Engineering common first year) and programme DT009 in the Dublin Institute of Technology. Over the course of this semester, you will work in teams of (usually) three to design and build a robot that will compete in a RoboSumo tournament. The tournament consists of a series of bouts in which two robots at a time compete to push each other off a table (the arena). A detailed set of rules are provided which impose constraints on the cost, weight, physical dimensions and various other elements of the robot design. It is up to each team to improvise within the specified constraints to produce the most competitive robot they can.

Provisional Schedule

There are 13 teaching weeks in the semester. The provisional schedule for the RoboSumo project is shown below. This schedule is subject to modification and is provided here as a general guide to help you plan your work.

  • Week 1 (this week): Ice breaker exercises, form teams, begin LED Flash Challenge.
  • Week 2: Complete LED Flash Challenge, begin work on Race to the Wall robot.
  • Week 4: Tutors verify that each student’s blog contains a post including text, an original photo and an embedded video.
  • Weeks 6-7: Race to the Wall competition.
  • Note: Two week break for Easter between weeks 9 and 10.
  • Week 9: Tutors verify that each student’s blog contains documentation of the Race to the Wall.
  • Week 12: RoboSumo tournament.
  • Week 13: Closing date for RoboSumo blog entries.

Some things to be aware of

  • We are here to help you learn to manage your project effectively as a team. We will do our best to facilitate your work, but…
  • We are not here to tell you what to do every step of the way. You are expected to carry out independent research to figure out what you need to do to complete this project. We want to help you but we need you to be independent.
  • There are limits to what we can provide in terms of materials and tools. You will probably need to source materials and/or access to tools independently.
  • You will need some of your own tools – e.g. snips, pliers.
  • You and your teammates will need to look after your own robot, materials and components (including the RoboSumo kit) throughout the project. This applies as of today!
  • You need to supply your own batteries.
  • Please do not take apart the yellow motors we give you.
  • Please do not remove the backing sheet from the mini breadboard we give you (unless you’re absolutely certain that you want to stick it to something permanently).

What to do today (Wednesday 24-1-2018)

In today’s lecture (2-3pm in room KE3-008, which is the large lecture theatre on the third floor of the main building in Kevin St), I will describe the project objectives, review the provisional schedule and explain how the assessment works.

In today’s lab (3-6pm in rooms KEG-012, KEG-014 and KEG-036 on the ground floor of the main building in Kevin St), you have four jobs to do. The first three are quite short; the fourth is more challenging.

  1. Meet your tutor(s) – this is the lecturer who will supervise your lab group and assist you in completing the project.
  2. Do some icebreakers.
  3. Form teams of 3 – your tutor will assign each team a number (see number range for each group below) and give you a set of components. It is your responsibility to look after these components (like all your equipment and materials) throughout the project.
  4. Complete (or at least make significant progress on) the LED Flash Challenge. See the previous post on this blog for details.

Each team must have a unique name and team number. Your tutor will assign your team a number from the range allocated to your group, as shown below:

  • Teams 50-59: DT066A Group A1 with John in KEG-012
  • Teams 60-69: DT066A Group A2 with Emma in KEG-014
  • Teams 70-89: DT066A Groups B1 and B2 with Ted/Gavin in KEG-036
  • Teams 90-99: DT009/2 teams (they’ll be in each of the competitions)

Note: Tutors, please make a list of teams in your group that includes team number and team members! (Team name too, if known)

Your kit today will include:

  1. 1 x mini breadboard
  2. 1 x Arduino Nano (with ATmega 328 microcontroller)
  3. 1 x mini USB cable
  4. 2 x green LED
  5. 2 x 220 Ohm resistor

Next week, once you have completed the LED Flash challenge, you will receive the following additional items:

  1. 2 x Arduino Nano (with ATmega 328 microcontroller)
  2. 2 x mini USB cable
  3. 1 x 4AA battery holder with built-in switch
  4. 2 x yellow geared DC motor
  5. 1 x SN754410NE driver chip
  6. 1 x TCRT5000 infrared reflective sensor
  7. 1 x microswitch
  8. 1 x 1000uF electrolytic capacitor
  9. 4 x green LED
  10. 4 x red LED
  11. 4 x yellow LED
  12. 8 x 220 Ohm resistor
  13. 8 x 10 kOhm resistor
  14. 2 x 100 kOhm resistor
Posted in Uncategorized | Leave a comment

LED Flash Challenge – Semester 2, 2017/2018

We’re beginning RoboSumo with a short competitive puzzle called the LED Flash Challenge. No formal assessment weight is attached to this challenge, but we’ll keep a close eye on who does well. In this challenge, doing well means two things: getting it working quickly and, more importantly, trying to understand what you’re doing.

In today’s lab (and for some of you part of the next lab) you’ll be working with your team to complete two tasks:

  1. Build a simple breadboard circuit for the Arduino Nano and program it to blink an LED on and off.
  2. Add a second LED to the circuit and reprogram the Arduino to transmit a specific binary sequence as a series of flashes from the two LEDs.

The first task is very prescriptive, which means that we’ll basically tell you exactly what to do, but to complete the second task you’ll need to think for yourselves.

You need a team number to complete this challenge. Your tutor will assign your team a unique number within the range shown below:

  • Teams 50-59: DT066A Group A1 with John McGrory in KEG-012
  • Teams 60-69: DT066A Group A2 with Emma Robinson in KEG-014
  • Teams 70-89: DT066A Groups B1 and B2 with Ted Burke and Gavin Duffy in KEG-036
  • Teams 90-99: DT009/2 teams with John McGrory

Part 1: Blinking LED

This task is relatively straightforward and shouldn’t take you too long to get working. Open the link below in a new tab and follow the instructions as far as the end of Part 1. Once your LED is blinking, come back here. (Note: The LED you receive may be a different colour and/or shape to that shown in the instructions.)

Instructions for Blinking LED example

Once your LED is blinking, there are four things you need to understand before moving on:

  1. How one of the Arduino pins (D2) was turned into a digital output.
  2. How the LED is turned on.
  3. How the LED is turned off.
  4. How to delay the program for a specified number of milliseconds, so that the rate of the LED blinking can be controlled.

Once you understand these four things, you have finished this part of the task (the easy part) and it’s time to move on to the LED Flash Challenge.

Part 2: LED Flash Challenge

In this part, you’re going to modify your circuit to create a simple optical transmitter, which transmits a digital message (a sequence of 1s and 0s) as a series of LED flashes.

The message that you’ll transmit will be 2 bytes long (a byte is 8 bits, or 8 ones and zeros) and it will contain your team number (byte 1) followed by a second number calculated by subtracting your team number from 255 (byte 2).

For example, if your team number is 79…

  • byte1 = 79
  • byte2 = 255 – 79 = 176
  • byte1 + byte2 = 255

Here, let me explain how binary numbers work…

Try doing some independent research on binary numbers. There’s lots more great stuff on YouTube, Wikipedia, etc.

Specifically, you need to do the following:

  1. Modify the code to create a second digital output pin.
  2. Extend the circuit by adding a second LED (with current limiting resistor) to that digital output pin.
  3. Convert your team number into an 8-bit binary number. This is byte 1 of your message.
  4. Calculate the required value of byte 2 (so that byte1+byte2 = 255) and write it as an 8-bit binary number.
  5. Each byte will be transmitted as a sequence of ones and zeros, preceded by a start bit (1) and followed by a stop bit (0). That means your complete transmission will be 20 bits long. You should calculate this sequence ad write it down on paper first.
  6. To transmit a 1, turn LED1 off and LED2 on for 500ms.
  7. To transmit a 0, turn LED2 off and LED1 on for 500ms.
  8. To ensure the sequence is read correctly, transmit a long sequence of zeros (for about 5 seconds) before you transmit your message.
  9. As is typically the case in digital transmissions, each byte must be transmitted least significant bit first.

Let’s consider that example team number 79 again. As explained above, byte 1 is 79 and byte 2 is 146.

  • Before transmitting the sequence, send a “0” for about 5 seconds.
  • The first bit of the sequence is the start bit for byte 1 which is “1”.
  • Written as a binary number, 79 (seventy-nine) is 0b01001111. The “0b” prefix indicates that a number is being written in binary form – it’s not part of the number value. The byte is transmitted least significant bit first, i.e. in the following order: “1,1,1,1,0,0,1,0”.
  • The next bit is the stop bit for byte 1, which is “0”.
  • The next bit is the start bit for byte 2, which is “1”.
  • Written as a binary number, 216 is 0b10110000, so the next 8 bits are “0,0,0,0,1,1,0,1”.
  • The final bit is the stop bit for byte 2, which is “0”.

To summarise, the complete 20-bit sequence for team 79 would be as follows:


The validator for checking your transmission is a web application which I have posted at the following location:

I will set a validation station in KEG-036 where you can record your result once your circuit is working. Other tutors may set up validation stations in the other rooms, but that will depend on available cameras and light levels.

You are welcome to try the validator on your own laptop / PC. In principle, it should work on any modern PC with a webcam and up-to-date browser. However, since video capture is relatively new in HTML, I recommend using the current release of Google Chrome which is what I tested it in. Some people have successfully used it in the web browser on their phone.

Your tutor will be able to clarify anything you don’t understand about this.

Posted in Uncategorized | Leave a comment

RoboSumo Tournament semester 1 2017-2018 – 2pm Wed 29/11/2017

This semester’s RoboSumo tournament
takes place at 2pm tomorrow,
Wednesday 29th November 2017
in room KEG-036, DIT Kevin St

Click here for Live Tournament ranking
(Note: All rankings are provisional and subject to change)

Please review the following information carefully from start to finish.

Tournament time and location

The tournament will commence at 2pm on Wednesday 29th November 2017 in room KEG-036, which is located in one of the smaller side corridors on the ground floor of the main building in DIT Kevin St. Weigh-in and robot validation will take place from 2-3pm. The first bouts will commence at 3pm. During the initial “sorting” phase of the tournament, two competition arenas (sumo tables) will operate in parallel in room KEG-036.

The exact duration of the tournament will depend on how quickly things progress, but we aim to be completely finished by 5pm. To ensure that the tournament proceeds efficiently, teams must comply with the instructions of the referee(s) without dispute at all times.

Robot Weigh-in – 2:00pm in KEG-036

Before your robot can compete in any sumo bouts, it must weigh-in and be measured to ensure compliance with the competition rules.

  • The weight limit is 500 grams, as measured using the electronic scales in room KEG-036. This includes every part of the competing robot, including batteries.
  • The size limit is 10cm x 10cm when viewed from above (no part of the robot is allowed to be outside this boundary). The size limit will be strictly applied.

Teams should present their robots for the weigh-in at 2:00pm in room KEG-036. One of the tutors will act as compliance officer, managing the weigh-in. He/she will run through a checklist with each team. He/she will also provide Q6a feedback forms for you to complete and return with your robot after the tournament.

Sumo Bouts – 3:00pm in KEG-036

From 3:00pm onwards, teams should be continuously present in room KEG-036 and ready to compete immediately whenever summoned to one of the arenas. If a team is not ready when they are called to compete in a bout, their opponent will be granted a walkover in that bout. However, that team remains eligible to compete in subsequent bouts (until they are eliminated from the tournament).

Submitting Your Robot for Formal Assessment – KEG-036

Once your team is eliminated from the competition (or has won!), you must submit your robot for assessment. This is critically important for your final grade. The compliance officer (or another tutor) will be managing the submission of robots and will run through the following checklist with each team:

  1. Have you submitted your robot? A clear label showing the robot’s name should be securely attached. Suitable labels will be available in KEG-036.
  2. Optional: have you attached a 1-page feature guide to your robot? This sheet can be used to highlighting interesting design features that might not be immediately obvious to the assessment panel during the design assessment. There is no special format for this page – if you’re including one, just make it clear, fold it up, and attach it securely to your robot.
  3. Have you provided a completed robot information sheet? This sheet includes: team/robot name, team number, tutor name, name of every team member, blog address of every team member. Blank paper copies of the robot information sheet will be available in KEG-036.
  4. Have you returned a completed Q6a feedback form for each team member? Blank paper copies of the Q6a form will be provided at weigh-in.

Please do not leave without submitting your robot. Doing so may have a catastrophic effect on your grade.

DIT tournament rules

The RoboSumo tournament rules are those of the Robot Challenge “Mini” class, mostly as described in the Robot Challenge rules PDF document. However, those rules make provision for tournament organisers to introduce local rule changes as appropriate.

The following rule variations apply in the DIT RoboSumo tournament:

  1. No infrared starting devices are used. Instead, teams position and start their robots manually at the beginning of each bout, as instructed by the referee. Following manual starting, each robot should remain still for at least 2 seconds. (In most cases, this will simply require the inclusion of a 2-second delay in the robot’s Arduino program.) Robots which do not observe the 2 second delay at the start may still be allowed to compete at the discretion of the referee, but may be penalised by being placed in a disadvantageous starting position.
  2. The duration of each bout is limited to 60 seconds. At the discretion of the referee(s), the bout duration may be reduced further to speed the progress of the tournament. (Note: In the past, we have sometimes reduced the bout duration to 30 seconds to speed things up.)
  3. If both robots remain in the arena when the time limit for the bout expires, the referee will decide the winner based on each robot’s distance from the centre of the table (the closer the better), robot activity/behaviour during the bout, attitude/behaviour of each team during the bout, and/or other criteria at his/her own discretion. The referee may explain the criteria upon which the winner of a bout was chosen, but is not required to do so.
  4. When a bout fails to produce a clear winner, the referee may, at his/her own discretion, order the bout to be replayed.
  5. During most phases of the competition, matches will consist of a single bout. However, in the latter (knockout) stages of the competition the number of bouts in each match may be increased (e.g. best of 3 or best of 5), depending on the time available.
  6. The dimensions of each arena will be similar to those described in the Robot Challenge rules (77cm diameter with a 2.5cm white border), but may deviate slightly from them. However, the white border will not be less than 2.5cm in width.
  7. A robot which displays no responsiveness to its opponent or its surroundings for a significant period of time may, at the referee’s discretion, be disqualified from a bout. In particular, please note that robots which simply spin on the spot will be viewed very unfavourably by the referees unless they exhibit other behaviour which provides evidence that the spinning forms part of a meaningful control strategy.
  8. Each team’s robot spending limit is €70. This figure must include the cost of all components included in the final robot, as it is presented for the tournament validation process, with the following specific exceptions. The €70 budget does not include the cost of components or materials purchased but not used in the final robot. It does not include any cost incurred for postage and packing. Most recycled materials which are obtained free of charge do not need to be accounted for in the robot budget, but specialised components which would not be available to other teams through normal scavenging (e.g. remote control servos) may need to be represented by an indicative cost. In general, the referees do not systematically verify the cost of every robot, but where a specific dispute arises or it is suspected that a robot may be in breach of this rule, a team may be asked to provide evidence of their total spending (e.g. by providing receipts or showing where each component used can be purchased for the claimed price). Where a team is suspected to be in breach of this rule and cannot prove otherwise, the referees may apply a penalty of some kind or even disqualify a robot from the tournament.

Important note: Every effort has been made to compose the rules of each bout and the structure of the tournament as a whole in a way that is fair and consistent, but since it is impossible to anticipate every eventuality, the referee(s) must have ultimate discretion to overrule any regulation or introduce a rule change at any time.

Tournament structure

The tournament is divided into two main phases – a sorting phase and a knockout phase. Each team must also complete a validation process prior to competing in their first match.

Validation process

The validation process ensures that each robot complies with the restrictions on size and mass imposed by the Mini class rules. Teams who do not successfully complete the validation process are not eligible to compete in the RoboSumo tournament. Teams who are unable to field a compliant robot may still be asked to compete in one or more exhibition bouts for assessment purposes, but they cannot progress in the tournament.

  • The mass of the robot, including batteries and all parts which will be attached to the robot during a bout, must not exceed 500 grams.
  • The footprint of the robot must not exceed 10cm by 10cm. Specifically, the entire robot and all parts attached to it, must fit within a cuboid (with vertical sides) of 10cm width and 10cm depth. Height is not specifically restricted. Note that robots are permitted to expand beyond their 10cm by 10cm footprint after the start of a bout, as described in the Robot Challenge rules.
  • All ground contact points that bear the weight of the main body of the robot must fit within the 10cm x 10cm footprint throughout the entire bout. It is permissible for parts of the robot to touch the ground outside the 10cm x 10cm footprint once the bout is underway, but the weight of the main body of the robot must not rest on them.

Following validation (the “weigh-in”), if a team makes any change to their robot which increases its size or mass, they must repeat the validation process prior to competing in a match.

Sorting phase

The referees will divide the competing teams into two pools. The initial ranking in each group will be determined primarily by the results of the Race to the Wall challenge. The objective of the sorting phase is to select the top 8 teams from each pool. A variation on the so-called bubble sort will be used for the majority of the sorting phase. However, the referee in charge of each arena may deviate from this pattern at his/her own discretion to resolve any unforeseen ranking issues or anomalies.

In each group, the sorting phase will conclude until the referee is satisfied that he/she has identified which 8 teams should progress to the knockout phase of the tournament.

Knockout phase

The 8 top-ranked teams from each group (A1, A2, A3…A8 and B1, B2, B3…B8) will proceed to the knockout phase of the tournament. When a team loses a match in this phase, they are eliminated from the tournament. The referees will decide the number of bouts per match in each stage of the knockout phase.

The matches in this phase of the tournament are as follows:

  • 8 Last-16 Matches: A1 v B8, A2 v B7, A3 v B6, A4 v B5, A5 v B4, A6 v B3, A7 v B2, A8 v B1
  • 4 Quarter Finals: A1/B8 v A5/B4, A2/B7 v A6/B3, A3/B6 v A7/B2, A4/B5 v A8/B1
  • 2 Semi Finals: A1/B8/A5/B4 v A3/B6/A7/B2, A2/B7/A6/B3 v A4/B5/A8/B1
  • 1 Final: A1/B8/A5/B4/A3/B6/A7/B2 v A2/B7/A6/B3/A4/B5/A8/B1

Laboratory access during the tournament

  • There will be no RoboSumo lecture from 2-3pm on the day of the tournament. Instead, teams will proceed directly to KEG-036 at 2pm for the tournament weigh-in.
  • Access to laboratories other than KEG-036 before 3pm on the day of the tournament will be subject to the limitations of the timetable for each laboratory (other classes may be timetabled in some rooms before 3pm).
  • Room KEG-036 will be open from 2pm onwards. However, space may be limited due to re-organisation of tables for the tournament.
  • The normal lab facilities will be available from 3pm onwards, to facilitate teams who wish to carry out repairs or adjustments to their robots. However, bear in mind that if the referee summons you to a match and you are not present, your opponent will be granted a walkover victory.

Competitor check list

Inevitably, many teams will face technical issues on the day of the tournament, and it’s impossible to foresee every problem. However, there are certain issues which we see every year:

  1. PLEASE PLEASE PLEASE ensure that your robot is compliant with the size and weight limits. Yes, 101mm is too much! And yes, 501 grams is too much! To avoid unexpected problems, please leave some margin for error. We need to be absolutely strict about these limits and butchering your carefully crafted robot at the last minute to reduce its size or weight can be a heartbreaking experience.
  2. If you haven’t already tested your robot actually driving around, please do so BEFORE the tournament. Bizarrely, every year we see teams who leave it until the very last minute to attach the wheels to their motors for the first time. Unfortunately, many of them discover at that point that their gearing is totally inappropriate and the robot cannot actually move.
  3. Focus on the basics. This means moving around and responding to the white border of the arena so that you don’t accidentally drive out of it. Even if you don’t have a working rangefinder you can still expect to win some bouts just by staying mobile and staying on the table.
  4. Speaking of which… don’t be too reliant on your rangefinder / proximity sensor (if you’re using one). These sensors can sometimes completely fail to detect an opponent, depending on its shape and material. Design your code so that the robot will still do something intelligent if it doesn’t detect the opponent.
  5. Make sure your robot doesn’t simply spin around the spot for the entire bout. This behaviour will be viewed very unfavourably by the referee.
  6. Make sure you bring plenty of spare batteries.

Finally, remember to get plenty of photos and videos of your robot (and team) in the run up to and during the tournament. Of all the evidence you will provide on your blog, photos and videos are some of the easiest to create, and they can really help to tell the story of your project.

Finally, best of luck to all of you!

Posted in Uncategorized | 1 Comment