title of the teaching unit · web viewrev: 1.0 (october/2016) author: labsland experimentia s.l....

81
This activity has been designed for use with the Labsland Arduino Robot Lab - Visual . You can find more labs and activities at: https://labsland.com Didactic unit INTRODUCTION TO PROGRAMMING AND ROBOTICS THROUGH THE LABSLAND REMOTE LABORATORY Rev: 1.0 (October/2016) - 1 -

Upload: others

Post on 10-Aug-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Didactic unit

INTRODUCTION TO PROGRAMMING AND ROBOTICS THROUGH THE LABSLAND REMOTE LABORATORY

Rev: 1.0 (October/2016)

Author: LabsLand Experimentia S.L. ([email protected])

- 1 -

Page 2: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Table of contents

1. Title of the teaching unit 4

2. Substantiation and justification 4

3. Educational goals 5

3.1 Objectives 5

3.2 Contents 5

3.3 Competences 5

4. Timing 6

5. Methodology 6

5.1 Methodological foundations 6

5.2 Methodological principles 7

5.3 Student organisational strategies 8

5.4 Equipment and resources 8

5.5 Organisation of time 9

5.6 Organisation of space 10

5.7 Mainstreaming 10

6. Activities 10

6.1 Introduction to Basic Robotics: Actuators and Sensors 11

6.2 Accessing the Remote Laboratory 14

6.3 Getting to know the Remote Lab interface 15

6.4 What is an algorithm? 17

6.5 Our first programme in the Remote Laboratory: moving the robot 20

6.6 Programming the LEDs 30

- 2 -

Page 3: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.7 Loops 36

6.8 Infrared sensors 45

6.9 Conditions 51

6.10 Variables 58

6.11 Functions 63

6.12 Following the line 68

6.13 Getting out of the labyrinth 75

7. Evaluation 79

7.1 Assessment criteria 79

7.2 Evaluation Procedures and Instruments 81

8. Conclusion 83

9. Bibliography and webography 83

1. Title of the teaching unit

"Initiation to programming and robotics through the LabsLand Remote Laboratory".

- 3 -

Page 4: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

2. Substantiation and justification

The learning of programming is primarily practical and is obtained through exercise. Through the effort required to discern the most appropriate way to solve each problem, the ability to efficiently use the different code elements available is acquired. This is why this type of study cannot be approached in a purely theoretical way, but it is necessary to propose a clear objective towards which the students can orient their work.

This Teaching Unit is aimed at students in Secondary Education and High School, although it could be used in other school years given the novelty of their learning. Among the subjects most closely related to the content are Science, Technology, Engineering and Mathematics - academic disciplines known by the acronym CTIM or STEM in English. At the same time, there is also room for the rest of the subjects, such as the teaching of foreign languages, Spanish language and art education, due to their strong cross-cutting component.

The main objective of this unit is to establish knowledge of basic robotics, developing robot control activities that cumulatively use the different tools provided by programming languages. The organisation of the activities is based on this progression.

After some basic fundamentals of robotics and algorithms, students are familiarised with the online programming interface used for the practical experiments and some simple ways of interacting with the actuator systems of the available devices are proposed. Control loops are then explained, so that sensory systems can be used appropriately, followed by the conditions, variables and functions required to produce complex control programs.

The unit ends with two robot programming projects, to reinforce knowledge and test the skills acquired by the students: firstly, a control system is generated for a robot that follows a simple path and, by increasing the complexity of the corresponding code, it is possible to find the exit of a labyrinth. At the end of this work, the students will not only have acquired basic programming notions, but will also have been able to observe their usefulness in a practical environment.

3. Educational goals

3.1 Objectives

This Teaching Unit will contribute to achieving the following general objective:

- 4 -

Page 5: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

- To develop students' cognitive capacities for critical analysis and engineering skills by teaching them programming skills and the assembly of robots through a block programming language.

In each of the activities that make up this didactic unit, the specific objectives to which each one contributes will be detailed, with the aim of achieving the acquisition of the general objective.

3.2 Contents

The contents to be worked on in this Didactic Unit are:

1. Knowledge of a robot and basic fundamentals of robotics2. Remote laboratory interface3. Algorithms and flowcharts4. Our first programme in the Remote Lab: moving the robot5. LED unit6. Loops7. Infrared sensors8. Conditions9. Variables10. Functions11. Line-following robot12. Labyrinths in robotics

The specific content of each activity is specified.

3.3 Competences

This Didactic Unit will contribute to the achievement of the following basic competences:

● Competence in information processing and digital competence.● Competence in learning to learn.● Competence in autonomy and personal initiative.● Competence in knowledge and interaction with the physical world.● Competence in linguistic communication.● Social and civic competence.● Cultural and artistic competence.● Digital competence.● Sense of initiative and entrepreneurial spirit.● Mathematical competence and basic competences in science and technology.● Cultural awareness and expressions.

- 5 -

Page 6: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

4. Timing

This Teaching Unit, as mentioned above, will be used mainly in Science, Technology, Engineering and Mathematics (STEM) subjects, although it can also be used in any other subject.

It will be organised in 12 theoretical-practical activities and is estimated to last approximately 24 hours in total. Since the computer science subject is expected to be taught for 3 hours per week, the proposed content would be spread over 8 weeks of classes.

Weeks 1 and 2 Introduction to robotics and basic algorithms Themes 1 to 4

Weeks 3 and 4 Control loops and sensing systems Themes 5 to 7

Weeks 5 and 6 Conditional statements, variables and functions Themes 8 to 10

Week 7 Programming a line-following robot Item 11

Week 8 Robotic maze solving Item 12

The distribution of activities has been done in this way because the concepts are better assimilated when they are taught in this order. The aim is to start from the most general and simple methods to finally reach the final objective, which is the programming of a robot that is able to get out of a maze.

5. Methodology

5.1 Methodological foundations

The methodological approach to be followed in this Didactic Unit will seek the integration of scientific, technological and organisational contents, the capacity for self-learning and the ability to work in a team. In order to achieve the educational objectives proposed in the module, the proposed methodology will mainly seek to encourage motivation and awaken the interest of the students in the corresponding contents mentioned above.

5.2 Methodological principles

The existence of methodological principles and strategies is justified because we must start from a didactic way of proceeding, which facilitates in an active, meaningful, globalising, constructive and socialising way; the functionality of the teaching-learning process, under a climate of affection and trust, and in accordance with a creative environment, in which equal opportunities among students are favoured.

- 6 -

Page 7: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Some of these methodological principles are:

● To promote meaningful and progressive learning, starting from what is mastered to the required competences.

● To promote varied learning through the use of different technological techniques and variation in practical activities.

● Organise teaching activities in a progressive way, so that students have a systematic and coherent guide that favours the achievement of learning.

● Encourage cooperative and collaborative work, when possible, so that students become familiar with shared tasks, the dedication of time, space and procedures for reaching agreements in the programming and development of projects.

● Motivate activity, research and experimentation in students so that they can actively build their own knowledge schemes based on what they already know and what is offered to them, leaving aside mere contemplation and offering them strategies that help them to be creative, strengthen their imagination and their capacity for observation.

● It is important to continuously, globally and individually evaluate the teaching-learning process and to facilitate the participation of the students in the evaluation process of all the activities carried out.

Teachers are recommended to act as a guide in the learning process, providing the necessary resources while advising and guiding the acquisition of knowledge, skills, abilities and attitudes related to robot programming and assembly.

5.3 Student organisational strategies

It is recommended to organise the classroom in a flexible way in order to encourage autonomous teaching-learning and assessment activities, as well as those shared with the class-group. For this purpose, different types of groupings will be used, taking into account the number of people cohabiting in the space:

● Large group

This organisational model could be interesting because it allows all the students to cooperate in order to carry out productions that require joint involvement. At the same time, when presenting the robotics projects, everyone could suggest proposals for improvement, contributing to the generation of satisfactory feedback.

● Small group

- 7 -

Page 8: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Groups of 3 and/or 4 people could be formed to develop collective activities, encouraging cooperative and collaborative work. In this way, a greater number of opinions and ideas would emerge when carrying out the various projects using the Brainstorming technique.

● Individuals

This type of activity could be carried out for greater student introspection. In addition, in cases where it is not possible to access the remote lab together, this style of grouping will be used.

5.4 Equipment and resources

In order to enrich and encourage the development of the activities, the following resources will be used in this Didactic Unit:

● Human resources

○ Teacher

○ Students and their families

● Technical and material resources

○ Consumables (paper, pencil, etc.)

○ Computers with Internet connection

○ LabsLand account

● Environmental resources

○ Educational centre and regular classroom. Also personal spaces such as the family home with Internet connection.

5.5 Organisation of time

Taking into account the difficulty of each of the activities and the estimated time needed to carry out each of them, the proposed timetable is as follows:

Activity Theory Exercises

1 40 min 1 hour and 20 min

2 50 min 1 hour and 10 min

- 8 -

Page 9: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

3 50 min 1 hour and 10 min

4 1 hour 1 hour

5 25 min 35 min

6 1 hour 1 hour

7 30 min 45 min

8 1 hour 1 hour

9 30 min 1 hour

10 1 hour and 10 min 1 hour and 20 min

11 1 hour and 20 min 1 hour and 20 min

12 1 hour and 30 min 1 hour

5.6 Organisation of space

Spatial organisation will have a decisive influence on the way activities are carried out. In a classroom, it must be flexible and in accordance with the needs that arise.

The only work spaces required for the activities proposed in this Didactic Unit, within the educational centre, will be:

– Ordinary space: The classroom, for theoretical and manual exercises.

– Specific Space: The computer classroom, from which students can connect to LabsLand's online remote laboratory.

5.7 Mainstreaming

The cross-curricular themes contribute in a special way to the education of moral and civic values, understood as an education at the service of the training of people capable of rationally and autonomously constructing their own system of values and, on the basis of these, also capable of critically judging the reality in which they live, and intervening to achieve its transformation and improvement (Temas transversales y desarrollo curricular, MEC, 1993).

The transversal themes that will be worked on in this Didactic Unit, apart from those already mentioned, are consumer and user education, education for coexistence and peace, education for

- 9 -

Page 10: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

human rights, health education, environmental education and education for equal treatment between the sexes. This is because the aim is not only for students to learn to programme, but also for them to acquire values to work in teams, to achieve respect for their peers, to create projects that contribute to social improvement and to develop their creative skills, so that all the contents are used to create independent and autonomous beings in their learning process.

It would be interesting to propose cross-cutting themes to students, so that they can contextualise the different projects related to robotics. In this way, pupils could feel more motivated knowing that their product could have a usefulness and social repercussion.

6. Activities

The specific guidelines for organising the distribution of activities will be based on Merrill's sequence of activities (activation, demonstration, application and integration), but mainly according to the different stages of the learning process.

Each of the activities is divided into initial activities, where introductory, orientation and motivation activities will be carried out to detect and evaluate previous knowledge and ideas with the aim of trying to modify stereotypes and achieve significant learning. Also, in in-depth activities, where the contents that will be dealt with at each moment will be presented, using the available means and applying an active methodology, as well as proposing individual and/or group activities, aimed at consolidating what has been explained. Finally, there are consolidation activities, which will be related to research activities, design and execution of projects.

6.1 Introduction to Basic Robotics: Actuators and Sensors

Specific objectives:

● To know the internal components of the Robot and their corresponding use.● Know the differences between the two main types of Robots.

Specific content:

● Definition of Robot● Origin of the term Robot● Systems that make up a Robot (control, sensory, actuation)● Main Robot Types (manipulative, mobile)

Definition of Robot

- 10 -

Page 11: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

A 'robot' is any programmable machine capable of performing one or more activities autonomously. It must be able to collect information and interact to a certain extent with its environment, to modify its behaviour and thus make decisions about the functions to be performed.

The word "robot" comes from the Czech "robota", meaning "hard or forced labour". It was created by the writer Karel Čapek in his play "Universal Robots Rossum" (1920), but its use spread through the science fiction works of the American writer Isaac Asimov.

Main Robot Systems

Every robot consists of three main systems:

- The control system, usually in the form of an auxiliary computer, which enables it to interpret the sensed data and take appropriate action on the basis of that data,

- The sensory system, which includes all those attached devices that allow it to gather information about its environment and its own state,

- The actuation system, to which belong all those physical elements of the robot that allow it to perform actions on its environment or on itself.

For simplicity, the general structure and behaviour of a robot can be compared to that of a human being. Thus, a person's control system would correspond to their brain, which would process information from the sensory system (the senses, pain receptors, hormone levels, etc.) and control the activity of the actuator system (movement of the joints and all the natural functions of the body's organs). In later topics it will be noted that the information gathering and decision-making methods of robots are equally similar to those of a human being.

Main types of Robot

There are two main types of robots:

- Manipulator robots are usually anchored to a surface, but consist of a chain of joints that allow them to reach and perform actions at specific points in their vicinity. These are the robots commonly found on factory assembly lines. The end element of a manipulator

- 11 -

Robot status

Actuation

systemControl system

Sensory system

Robot environm

ent

Page 12: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

robot, known as the 'end effector', is often interchangeable to enable it to perform different actions, such as picking up objects, painting or welding.

- Mobile robots do not have end-effectors, but have the ability to move around their environment, usually by means of wheels. They typically require a more accurate and comprehensive sensing system than manipulators, as their work area may be less predictable than that of an assembly line.

Of course, both types of robots could be combined together to produce a more complex machine, but from a programming point of view, each part would be independent.

Manipulator robot Mobile robot

PROPOSED EXERCISES

Motivation: Students are asked to think of fictional robots that they have seen in films and on television and to analyse which parts of them would correspond to manipulative robotics and which parts to mobile robotics, bearing in mind that some parts could be part of both modalities or neither of them.

Grouping: Whole class

Resources: Not required

Space: Classroom

Time: 20 minutes

Solution: In general, any part of a robot that has joints and can perform a specific activity, even if it is as simple as a variable orientation camera, are manipulators, while any element that allows the robot to change its position in space belongs to mobile robotics. The legs of humanoid robots would be an example of both modalities, as they have joints that have to be programmed but

- 12 -

Page 13: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

produce a displacement.

Development: It is then proposed to the students to use their imagination to design their own robots, combining manipulative and mobile elements.

Grouping: Individual

Resources: Paper and pencil

Space: Classroom

Time: 30 minutes

Solution: As students are likely to rely mainly on fictional elements, they are not expected to be realistic, only to understand the difference between manipulative and mobile robotics. Again, it is possible that they may include parts that do not correspond to either, but this is acceptable as long as they can realise this or make a reasoned argument if they disagree.

Consolidation: In small groups, students will share their designs and discuss the characteristics of each one, proposing improvements and combining them into a single design, which they will show to the rest of the class.

Grouping: Small groups (3 to 6 students)

Resources: Paper and pencil

Space: Classroom

Time: 30 minutes

Solution: The criteria for classifying elements described above are maintained. The teacher should check that the students are able to correctly identify each part of their designs.

6.2 Accessing the Remote Laboratory

A remote robotics laboratory is a platform that, via the Internet, allows the operation of programmes carried out on a real robot to be tested. This environment can be accessed in different ways.

- 13 -

Page 14: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

As a teacher, you will have the option to access the lab from your institution's LabsLand space, and you can group different labs according to the group of students. In addition, you will need to provide students with a link or a way to access the lab. Depending on what you have chosen in the configuration of your institution's LabsLand space, they will be able to access it either directly through an LMS, or through a link.

As a student, you will need your teacher to specify the link or way to access the lab.

If you are unable to access the remote lab, please do not hesitate to contact us at the following email address: [email protected].

6.3 Getting to know the Remote Lab interface

Specific objectives:

● Know the interface of the remote laboratory to access its different sections.

Specific content:

● Definition of website, sitemap.

Once you have accessed the laboratory, you will find the following interface:

When you think the program is correct, click on the "Verify" button and the "Send to robot" button will be enabled. When you send the program to the robot, you will have the option to choose different circuits.

- 14 -

Page 15: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

The first circuit will send the program to any robot, the other two are specific.

After choosing the circuit type, you will see the robot. To make the robot execute the program logic, you will have to click on the "Program in Arduino" button.

- 15 -

Page 16: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

At this point, you will be able to interact with the robot and the program you have created. For the program to run correctly, before executing the program, it is advisable to move the robot to the centre of the circuit with the arrows shown in the image.

To return to the visual code and repeat the process indefinitely, click on the "Exit now" button.

6.4 What is an algorithm?

Specific objectives:● Develop skills for creating flowcharts● Organising activities according to the pattern of an algorithm

Specific content:● Definition of algorithm

- 16 -

Page 17: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

● Flowcharts

Definition of Algorithm and Flowcharts

An "algorithm" is a set of concrete instructions that, when executed in order, allow a task to be carried out. A cooking recipe or instructions for assembling a piece of furniture are everyday examples of algorithms.

Although algorithms must be coded in some programming language in order to be executed by a computer, there are alternative ways of representing them to make them easier for people to understand. Flowcharts serve this purpose and the most important elements of flowcharts are as follows:

● The start and end of an algorithm are represented by capsules,

● Individual actions, such as calculations and decision-making, using rectangles,

● The input and output data to be used by the actions, using rhomboids,

● The points at which the execution can take different paths depending on a certain condition, using diamonds,

● The elements are connected to each other in order by arrows.

When writing a program on a computer, it is highly recommended to first create a script or flowchart to remember which actions are to be implemented and in what order they are executed.

For example, let's suppose that we have the necessary parts to build a chair or stool. The assembly instructions, together with a possible program code and corresponding flowchart, would be as follows:

1. Take the seat upside down

2. Attach each of the legs to the seat.

3. Turn the structure around4. If the chair has a backrest,

look at the seat.

to assemble a chair: turn around (seat) for (each chair leg): fix (leg, seat) turn around (seat) yes (the chair has a

backrest): fix (backrest, seat)

- 17 -

Page 18: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

PROPOSED EXERCISES

Motivation: Students are asked to choose an activity they carry out on a daily basis and describe it in the form of a flow chart.

Grouping: Individual

Resources: Paper and pencil

Space: Classroom

Time: 20 minutes

Solution: It has to be taken into account that each learner can perform the same task following different steps. The correct use of the different forms of flowcharts (input and output, actions, data and decisions) should be assessed.

Development: In order to contrast the different algorithms that can describe the same task, each student will tell the class which one he/she has chosen for the previous exercise and those that are similar will be compared.

Grouping: Whole class

Resources: Not required

Space: Classroom

Time: 20 minutes

Solution: The teacher should allow students to discuss the efficiency of their algorithms, ensuring that they understand the time constraints imposed by the algorithms. As a rule, the proposed

- 18 -

NO

YES

Completed

NO

Attach the backrest to the

Is it backe

Turn the structure

YESAre

there

Attach a leg to the seat

Take the seat upside

Disassemble

Page 19: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

order of actions in an algorithm has to be respected.

Consolidation: The teacher will propose a complex task which the students should describe in the form of an algorithm. Examples could be "go to the moon", "get to the president" or "build a robot". The task does not have to be realistic or feasible; students can be allowed to use their imagination and fantasy.

Grouping: Small groups (3 to 6 students)

Resources: Paper and pencil

Space: Classroom

Time: 30 minutes

Solution: Again, the teacher should only check that the elements of the flowcharts are used correctly and that the sequencing of actions is respected.

6.5 Our first programme in the Remote Laboratory: moving the robot

Specific objectives:● Identify how the movement of the robot's wheels relates to the movement of the

whole robot● Learn how to program the Robot's movement

Specific content:● Definition of DC motor● Programming the movement of a Robot

Definition of DC motor

A direct current motor (also known as a DC or DC motor) is a component that converts electrical energy into mechanical energy, causing a continuously rotating motion on its shaft.

This type of motor is widely used in a wide range of household appliances and devices as well as in robotics. In our case we will use this type of motor to provide movement to the Robot available in Zumoline.

- 19 -

Page 20: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Programming the robot's movement

A basic feature of our robot is its ability to move. Let's imagine that we want to program our robot to be able to perform five types of movements: forward, backward, turn to the right, turn to the left and turn on itself. We must bear in mind that these movements must occur using only two motors and therefore two wheels. The speed configuration for each wheel depending on the movement we want to perform can be seen in the following image:

Go to Turn Rotate

As we can see, the different movements we want to generate depend mainly on the difference in speed between the two wheels. If we want the robot to move to the left, we would have to give a low speed to the left wheel and a high speed to the right wheel. If we wanted the robot to move forward or backward, we would have to give the same speed to each wheel. In the programming of the robot, for the assignment of different speeds we will introduce values between 0 and 255; with this we will be able to generate the different rotation speeds. In the following image we will see two examples of programming, one for the case of moving forward and the other for rotation to the left:

- 20 -

Page 21: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

We see that we first move forward for 2 seconds, then turn for another two seconds and return to the beginning.

We are now going to see how to build this program in the Remote Lab. The first thing to do is to enter the "Ardublocks" section and select the "Functions" family of blocks.

Now we select the first block "Arduino configuration - Arduino infinite loop" and drag it to the programme area in the central part of the environment. This block will make the blocks that we

- 21 -

Page 22: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

place inside it run continuously. Next, we select the "Motors" family of blocks to include the blocks related to the movement of the motors in the same way.

Now we are going to add the rotational speed of the motors. To do this, we select the "Mathematics" family of blocks and drag the first type of block "A number" to the free spaces in the blocks corresponding to the movement of the motors.

- 22 -

Page 23: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

A trick: when you need the same type of block in different places, you can use Ctrl+C and Ctrl+V to copy and paste the same block and use it elsewhere, saving you the time of selecting them one at a time.

At the moment, this program would act on the robot's motors, but we have not defined how long the motors have to move for the robot to do what we want it to do. To do this, we are going to include blocks that control the time through different delays. We open the "Time" block family and insert blocks of type "Wait - milliseconds" between the forward movement of the robot (i.e. after the second movement block) and after the turn (after the third movement block). Our program would look like this:

- 23 -

Page 24: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Once we have built our program we have to run it on the robot to see if it works as we want it to. When we enter the "Zumoline" section of the remote laboratory we select the program that appears in the "Your programs" section and we load it in the robot with the "Program" button. We can see in the central part of the environment how our robot moves following the commands we have programmed. This simple program does not allow us to control the robot interactively, and it is most likely that it will end up colliding with one of the limits of the robot's operating environment.

In order to have more control over the robot's movements, the Remote Lab includes a series of programmable buttons with which we can control the robot interactively. We will assign each button to a movement of the robot.

Back to the "Ardublocks" section, we are going to build a program so that when we press button A, the robot moves forward, when button "B" is pressed, the robot moves backwards and when button "C" is pressed, the robot turns.

To do this, after including an infinite loop block as in the previous example, we will open the "Logic" family of blocks and add an "if - do" block, as shown in the following image:

- 24 -

Page 25: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

The "if - do" blocks execute the block we connect in the "do" part as long as the condition expressed in the block we connect in the "if" part is met. In our example, we want the robot to move when a button is pressed. We are going to include the block that informs that a button has been pressed. To do this, we open the "Buttons" family of blocks and drag the "Button - as" block into our programme. This block allows us to assign a name to the three buttons available on the Remote Lab interface. We assign the three buttons as shown in the following image:

- 25 -

Page 26: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Now that we have defined the names of the buttons, we can select the corresponding button within the "is pressed" block. This block informs us if a certain button is pressed and we are going to use it to connect it in the conditional block that we have previously added as shown in the following image.

- 26 -

Page 27: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

We have also added the blocks that act on the motors as in the previous example. In this case, as it is the "forward" button, the speed of the two motors is the same so that the robot moves forward. We have also included a standby block so that the motors move during that time, and a "Change motor speed" block to keep the motors stopped as long as a button is not pressed.

Now we are going to include the blocks corresponding to the other buttons for the robot to turn or go backwards, as can be seen in the following image:

As in the previous example, we go to the Remote Lab section "Zumoline" and program our robot with the new example. In this case we will be able to control the movement of the robot interactively and remotely using the A (forward), B (backward) and C (turn) buttons. This program is very useful to use in combination with more complex programs that require the robot to start at a specific initial position. In this way we can manually place our robot wherever we want.

- 27 -

Page 28: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Note: in these examples we have seen conditional blocks, loops, etc. For the moment, it is not necessary to know how these blocks work in depth but to become familiar with the process of building and executing programs in the Remote Lab. In the following activities, each family of blocks will be explained in greater depth.

PROPOSED EXERCISES

Motivation: Write a program in Blockly that allows the robot to turn on itself.

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 10 minutes

Solution: Simply set the wheel speeds to the same value, but with a different sign.

Development: Write a program in Blockly that allows the robot to perform a path composed of all the types of movement explained.

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: Each student will be free to create his or her own preferred trajectory. All the motor programming sentences explained can be used, but there must always be a wait sentence after each modification of the velocities.

Consolidation: Write a program in Blockly that allows the robot to perform a specific path, given by the teacher, which should combine straight paths, curves and point turns. An example of this could be the following, where the turns are shown in red:

- 28 -

Page 29: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection, whiteboard

Space: Remote laboratory

Time: 30 minutes

Solution: The route followed by the robot should be as similar as possible to the one proposed, but students should be given the freedom to develop their creativity, perhaps contributing new elements to the robot's movement, as long as they can explain how they have programmed them.

- 29 -

Page 30: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.6 Programming the LEDs

Specific objectives:

● To know the characteristics of LED diodes● Learn how to program with LEDs using the visual programming language Blocky

Specific content:

● Definition of LED diode ● Operation of an LED diode

Definition of LED diode

A diode is a component that only allows current to pass in one direction and blocks it in the other. In the case of LEDs (light-emitting diodes), when they conduct current they emit light. These kinds of components are very inexpensive as well as being very efficient, consuming very little power, and are widely used in a wide variety of devices in our daily lives. Wherever there is light, an LED is probably being used.

Turning an LED on and off

As we have already mentioned, the LED is a component that emits light, so when programming it we must treat it as an actuator. As an actuator, an LED diode has only two states, on (HIGH) or off (LOW) like any digital actuator (i.e. one or zero).

- 30 -

Page 31: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Once we know the nature of this type of component, we can move on to programming the switching on and off of one of the robot's LEDs. We can see an example in the following image where we turn on one of the integrated LEDs:

On the other hand, the following image shows how to turn off the LED:

In this way we can switch the LEDs integrated in the robot assembly on and off. This block can be found in the "Leds" menu, as shown in the following image:

Flashing an LED

To make an LED blink, the first thing to do is to turn on the LED, as the robot controller board acts very fast if we program it to turn off the LED after giving it the ON command, it will pass from one command to another too quickly and it will seem that the LED always stays on. To avoid this effect, we have to wait for some time using the Wait block. This block makes the program wait for the number of milliseconds we put inside it; as we want the LED to flash every second, we have put 1000 milliseconds inside the block. After this wait, we can turn off the LED and, as the

- 31 -

Page 32: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

program runs cyclically, we must wait another second before returning to the beginning. In the following image we can see an example of the programming:

The "Wait" block is located in the "Time" section, as can be seen in the following screenshot:

Once we have built our program, we will have to run it on the robot to see if it works as we want it to. When we enter the "Zumoline" section of the remote laboratory, we select the program that appears in the "Your programs" section and we load it into the robot with the "Program" button. We can see at the bottom of the environment how the LED flashes at the speed we have set in our code.

- 32 -

Page 33: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

PROPOSED EXERCISES

Motivation: Write a program in Blockly that allows two LEDs to flash simultaneously. The teacher will guide the students to enable them to arrive at the correct solution.

Grouping: Whole class

Resources: Computer with internet connection

Space: Remote laboratory

Time: 10 minutes

Solution: Since the LEDs must be switched on and off at the same time, the solution is simple:

Development: Write a program in Blockly that allows two LEDs to flash alternately.

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 5 minutes

Solution: Again, as the LEDs change at the same time, the solution is very simple:

- 33 -

Page 34: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Consolidation: Write a program in Blockly that allows two LEDs to flash at different rates. Students will be asked to start by making one of the LEDs flash twice as fast as the other, but other combinations are allowed.

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: As the LEDs are no longer synchronised, the timeouts and actions can be randomised, but the following restrictions must be observed

● One of the LEDs must receive more commands than the other.

● Between every two actions associated with the same LED there must be at least one waiting time (but these times do not have to be all the same).

● The actions of each LED must alternate (off, on, off, on...).

● The first and last action of each LED must be opposite (if it starts on, it must end off and vice versa).

A valid example could be:

- 34 -

Page 35: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.7 Loops

Specific objectives:

● Understanding the concept of control loops● Understanding the structure of the control loop (while/for)● Detect the most favourable conditions for the use of a while loop or a for loop.

Specific content:

● Definition of control loop● While loop● Loop for● Breaking or continuing the loop

Definition of control loop

A control loop is a program segment whose execution is repeated according to certain conditions. Each repetition of a block of code is called an iteration. There are several types of control loops, depending on the needs of the code: the while loop and the for loop. Both can be found in the remote lab in the "Loops" panel.

- 35 -

Page 36: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

The while loop

The while loop repeats a block of code as long as a given condition is met. When the condition is no longer true, the loop ends and the program continues where it left off. Going back to the example in topic 3 of assembling a chair:

The program will start by looking to see if there are any unattached legs. As none have been placed yet, the code block "attach a leg to the seat" is entered and, once executed, the condition will be re-evaluated. This will be repeated until the condition is no longer true, when there are no loose legs. For example, for three legs:

as long as (loose legs remain):

attaching a leg to the seat

- 36 -

Page 37: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

1. Start2. Are there any loose legs? Yes, 3 → Attach a leg to the seat3. Are there any loose legs? Yes, 2 → Attach one leg to the seat4. Are there any loose legs? Yes, 1 → Attach one leg to the seat5. Are there any loose legs left? No → End

Some programming languages allow the use of a variant of the while loop known as do-while. The only difference between while and do-while is that the first option will always check the condition of the loop before starting, while the second always performs at least one iteration before checking.

This difference may seem trivial, but it can sometimes simplify the programmer's work. For example, when assembling the chair, we know that we start without any legs attached to the seat, so there is no need to check this at the beginning:

do:

attaching a leg to the seat

as long as (loose legs remain):

1. Start

2. Fixing a leg to the seat

3. Are there any loose legs? Yes, 2 → Attach one leg to the seat

4. Are there any loose legs? Yes, 1 → Attach one leg to the seat

5. Are there any loose legs left? No → End

The for loop (from/to)

- 37 -

StartAre there any

loose legs left?

Attach a leg to the seat End

NO

YES

StartAre there any loose legs left?

Attach a leg to the seat End

YES

NO

Page 38: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

The for loop repeats a block of code for a specified number of iterations. When all iterations have been completed, the loop terminates and the program continues where it left off. If you know the exact number of times you want to repeat a block, it is better to use the for loop rather than the while loop, as it is easier for the computer to execute.

Normally, a for loop needs a counter variable to let the program know which iteration it is in. This is achieved with a "count" block.

In this case, the variable leg would start with a value of 1 and increase by 1 until it reaches 4 (included). We can use the value of the counter of a loop by taking an "element" from the "Variables" tab of the remote laboratory and associating it to the corresponding variable

Some programming languages allow you to use a variant of the for loop known as foreach. While the for loop counts numbers for a given range, foreach extracts elements from a data set and returns them one at a time, until all of them have been visited.

For our example, assuming we had a dataset containing all the legs of the chair, foreach would allow us to take them one at a time instead of having to traverse the dataset manually. The main advantage of this method is that, if we don't know the number of elements in our dataset, we could step through it and let the program do the work of figuring it out for us.

Let's say we call the three legs of a stool "A", "B" and "C", which we have stored in a box labelled "legs". We would have two ways to access them:

- 38 -

Page 39: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

● With a for loop:

for (N ranging from 1 to 3):

attach the leg number N to the seat

1. Start

2. N = 1

3. ¿N ≤ 3? Yes, 1 ≤ 3 → Fix leg number N to the seat. As N = 1, it will be the leg A

4. N = 2

5. ¿N ≤ 3? Yes, 2 ≤ 3 → Attach leg number N to the seat. As N = 2, it will be the leg B

6. N = 3

7. ¿N ≤ 3? Yes, 3 ≤ 3 → Fix leg number N to the seat. As N = 3, it will be the leg C

8. N = 4

9. ¿N ≤ 3? No, 4 > 3 Fin→

● With a foreach loop:

for each (element P within the set "legs"):

attach P to the seat

- 39 -

Start N=1 ¿N ≤ 3?

Attach leg number N to

the seat

End

N=N+1

legs = {A, B, C}

NO

YES

Page 40: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

1. Start

2. P is leg A

3. Attach leg P to the seat

4. Are there any legs left? Yes, B and C → P is leg B

5. Attach leg P to the seat

6. Are there any legs left? Yes, the C → P is leg C

7. Attach leg P to the seat

8. Are there any legs left? No, all of them → End

It is important to remember that there is nothing to prevent nesting one control loop inside another. For example, if we wanted to check that a French pack of cards was complete by looking for its cards one by one, we could do:

for each suit (♥, ♠, ♦ and ♣):

for each card (A, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, J, Q and K):

search for the suit card

Breaking or continuing the loop

It is possible to break out of a loop if we decide halfway through that loop that we don't want to wait until the end. This is accomplished with a break statement, which simply sends execution to the next line just after the loop. If there is none, the program terminates.

- 40 -

StartEnd

legs = {A, B, C}

Are there still unused

objects in “legs”?

Attach P to the seat

P=1st “leg” object not already in

use

Page 41: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

It is also possible to decide during an iteration that we prefer not to finish it and go on to the next iteration. This is achieved with a continue statement (continue to the next iteration).

PROPOSED EXERCISES

Motivation: What would the program look like that would advance the robot until the central sensor detects a black line? Would it be better to use a while loop or a for loop?

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 10 minutes

Solution: In this case it is better to use a while loop because there is no known number of elements to traverse. The initial speed and detection threshold can be adjusted according to the learner's preference.

- 41 -

Page 42: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Development: How would the program make the robot progressively accelerate in a straight line, until each motor reaches 50, and then stop? Would it be better to use a while loop or a for loop?

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: In this case it is better to use a for loop because it is known in advance which elements to use: it will be all the natural numbers from 0 to 50. It is possible, if the students wish, to set an acceleration value other than 1.

- 42 -

Page 43: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Remember that the loop counter is automatically created as a variable, so to use its value we will have to look it up in the remote lab.

Consolidation: We want the robot to rotate clockwise and gradually slow down its rotation until it stops, and then start accelerating by turning on itself in the opposite direction. If we want to use a single loop for the whole process, how should it be programmed?

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: Simply use a for loop that goes from a negative to a positive speed value (or vice versa) and applies it with a different sign on both motors. This gives a smooth transition from one direction of rotation to its opposite.

- 43 -

Page 44: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.8 Infrared sensors

Specific objectives:

● Understanding the operation of an infrared sensor● Learn how to program an infrared sensor

Specific content:

● Definition and uses of infrared sensors● Programming of infrared sensors● Programming of a proximity sensor using an infrared sensor

Definition of infrared sensor

An infrared sensor, also called an IR sensor, is an electronic device that detects reflected light and is therefore able to differentiate between black and white or light and dark. IR sensors are present in everyday objects such as microwave ovens, automatic doors, burglar alarms and street lamps (they turn on at night and turn off during the day).

This is a digital component, i.e. it only returns two values: zero and one. When it detects black it returns the value zero (black absorbs light, therefore the reflected light, which is what the sensor measures, is zero) and when it detects white the value is one.

On the other hand, there are also other types of infrared sensors that are able to give back the distance they are from a certain object; these sensors are known as analogue IR sensors. The robot available at Zumoline has analogue IR sensors installed.

Sensor programming

- 44 -

Page 45: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

To see the measurements taken by this sensor we can use different devices, although for this example we will use the serial port available on the Zumoline. The serial port is nothing more than a tool that helps us to have information on the screen of what is happening in our robot. In the following image we can see where the serial monitor is located in the Zumoline environment (bottom right part of the environment).

The configuration of the sensor will cause it to return the distance it has collected. The programming of the sensor would be as follows:

- 45 -

Page 46: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

This programming block returns the information relating to the left proximity sensor, which detects objects placed to its left. On the serial monitor we will see a series of numbers indicating the distance to the object we are detecting. If we wanted to change the sensor that performs the measurement, we would only have to modify the block that follows "Read proximity sensors", adding the sensor from which we want to know the readings. The "Read proximity sensors" instruction returns information about all the proximity sensors implemented in the robot; when we use this instruction, we try to read all the sensors at the same time.

Proximity sensor programming

Now that we know how it works, we can move on to a proximity sensor like the one used in cars to help us park while reversing. For this setup, in addition to our sensor and an Arduino board, we will need to use the LED built into Zumoline. We will make a small program that, when the distance is less than 50 cm, will flash the LED as a signal. The frequency of the signal will increase as the object approaches the sensor. In this way, we can simulate a parking sensor for our robot. The programming for the proximity sensor is as follows:

For this exercise to work properly, it must be combined with the movement of the robot. Otherwise, the value displayed by the sensor is always the same, because the robot is not moving.

PROPOSED EXERCISES

- 46 -

Page 47: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Motivation: Write a program in Blockly that allows an LED to flash when we detect an object nearby via the infrared sensor. The LED should blink faster and faster depending on how close the object is, and if the object is far enough away, the LED should stay on.

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 15 minutes

Solution: The solution to this problem is very similar to the implementation of the initial LED example. As in that case, to make this example much more visual it is necessary to add some movement to the robot, in order to see how the measurements evolve. Although the movement of the robot is not incorporated, what is of interest in this case is to understand how the infrared sensor works and not the measurements it can return, so a valid solution for this problem is the following:

Development: Write a program in Blockly that allows to send by serial communication the distance measured by each of the robot's sensors.

- 47 -

Page 48: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 15 minutes

Solution: The solution to this problem is as follows:

Consolidation: Write a program in Blockly that allows the robot to move in the opposite direction when it detects an object. In order not to overcomplicate the code, it is assumed that the robot dodges an object that is in front of one of the sensors and, therefore, it is not necessary to consider all cases. In the case of not detecting an object, the robot must move in a straight line.

Grouping: Individual

- 48 -

Page 49: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Resources: Computer with internet connection

Space: Remote laboratory

Time: 15 minutes

Solution: The solution to dodge the obstacles on the right is to turn left, so the code is as follows:

6.9 Conditions

Specific objectives:

● Understand in which situations the use of a conditional sentence is necessary.● Logical organisation of a complex conditional statement

Specific content:

● Definition of conditional sentence● Elements that make up a conditional sentence● Selection blocks

Definition of conditional sentence

A conditional statement is a statement that determines whether a certain condition is met and makes the decision whether or not to execute a certain block of code.

- 49 -

Page 50: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Elements of a conditional sentence

The main element of a conditional block is the if statement, which encompasses those lines of the program that must be executed depending on its condition. For example, suppose we wanted to decide something by tossing a coin: if "heads" comes up, we do it; if "tails" comes up, we don't do it. Remember that the conditional blocks are found in the "Logic" tab of the remote laboratory.

You could decide to take an alternative action in case the initial condition is not met. This is achieved by the else statement, which must always be associated with an if statement: if can appear without else, but else cannot appear without if.

More complex decisions can be made by nesting conditional statements. For example, suppose we have three actions to carry out, A, B and C, and we want to decide which one to carry out by rolling a die. If the result is 1 or 2, we carry out action A; if it is 3 or 4, action B; and in the rest of the cases (5 or 6), action C.

Intuitively this could be coded by including an if/else block inside another block, but most programming languages allow you to simplify this organisation by using the else if statement, which works as follows:

- 50 -

YES

NO

YES

End

C

B

A

Is it 3 Is it 1 Roll a die

Page 51: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

is equivalent to:

You can always add as many else ifs as you like. Some programming languages allow you to summarise this code a little more by means of switch (selection) blocks, which allow you to compare a given value with several possibilities sequentially. They usually work as follows:

selection (given) {

case 1:

case 2:

do A

go to

case 3:

case 4:

if (die = 1) or (die = 2):

do A

otherwise, if (die = 3) or (die = 4):

do B

is equivalent to:

- 51 -

Page 52: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

if not:

do C

do B

go to

remainder:

When the desired case is found in a selection block (case in C++), it starts executing code, even entering the code corresponding to other cases, until the exit command (break in C++) is found. This makes it possible to associate the same action to several cases. Optionally, you can indicate what to do if none of the cases is satisfied, by means of the "rest" tag (default in C++); this tag must always go at the end of the selection block, so your code block does not need to end in an exit command.

For example, suppose "given" is 3. In the proposed code segment, execution would discard cases 1 and 2, but accept 3. Case 3 has no associated code, but would continue to execute within case 4 and "B" would be made. Only when the output command is encountered next, the selection block terminates and normal programme execution continues.

Selection block

There is an operand that allows you to quickly choose between two values without resorting to an if block. In C++, the line "condition ? a : b" will return a if the condition is true and b if it is not. In the remote lab, this is achieved with the "test" block:

The previous block is equivalent to:

- 52 -

Page 53: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

PROPOSED EXERCISES

Motivation: Students are asked to recall complex decisions they have had to make recently and, together, write them down in the form of a programme using conditional blocks.

Grouping: Whole class

Resources: Blackboard

Space: Classroom

Time: 20 minutes

Solution: The structure of the conditional blocks is simple, just evaluate each possible condition one at a time or in groups. For example, let's say that if it is cold in the street, we should take a jacket and check whether it is raining or not to take an umbrella, while in the opposite case, if it is very sunny, we should take a cap. The corresponding code would be:

yes (it is cold in the street):

I take a jacket

yes (rain):

I take an umbrella

if not, yes (it is very sunny):

I take a cap

Development: Conditional blocks can be combined with loops. We want our robot to accelerate progressively up to 50, but if it detects a black line in front of it , it breaks the loop and stops. What should your program look like?

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: Both cases were seen in activity 7.6, but one was to be handled by a for loop and the other by a while loop. At the moment, students cannot combine the two options because it would require the use of variables, which will be covered in activity 7.9. However, using the for

- 53 -

Page 54: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

loop as a basis for acceleration, the "break loop" block can be used to exit the loop when the line is detected.

Consolidation: We want our robot to perform certain actions based on the values provided by a for loop ranging from 1 to 10:

● If the number is even, one LED will light up. If it is odd, it will turn off. A "test" block must be used for this action.

● If the number is divisible by 3, the robot will move forward for one second.

● Otherwise, if the remainder of dividing the number by 5 is less than 2, the robot will stop for one second.

● In any other case, the robot will rotate on itself for one second.

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: Following the description of the problem, the programme would be as follows:

- 54 -

Page 55: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.10 Variables

Specific objectives:

● Understand what a variable is at the programming level.● Learning to use and program variables

Specific content:

● Variable definition at programming level● Scope of a variable at programming level

- 55 -

Page 56: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Definition of variable in programming

A variable is a piece of memory that a program reserves to store a piece of data. For practical purposes, a variable is a container in which a value is stored, so that it can be used later. In previous topics we have seen the use of data several times, such as loop counters. Internally, a program needs to create a variable whenever there is an element that can change value.

The moment a variable is created in a program is called a declaration. In most programming languages, the type of data that a variable contains must be decided at its declaration, in order to reserve the right amount of memory space. For example, a variable that is to contain only one letter will need less space than one that stores a full word. Once the type of a variable is decided, it cannot be changed. Typically, programming languages allow a variable to be given an initial value at the time it is declared.

Remember that, in the remote lab, we can create and access our variables in the "Variables" tab. By clicking on the name of a variable (by default, "element") we can change its name or create a new one. All the variables that have been created so far will appear in the drop-down menu.

Scope of a variable at programming level

The scope of a variable is the part of the program in which it can be used. The scope of a variable always begins with its declaration, but if it occurs in a bounded block of code, such as within a loop or conditional statement, the variable will cease to exist when execution exits its block.

A variable that is declared within a limited block of code is called a local variable, while a variable that is created at the beginning of the program and can be seen throughout execution is called a global variable.

A = 1 declaration of global variable A

for (i from 1 to 4): ..... declaration of the local v. i which is used as a counter

- 56 -

Page 57: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

B = A x i ..……… ..... ... ... declaration of the local variable B

A = A + B ..……… ..... ... ... the value of A is changed

display A shows the value of A

show i error i does not exist outside the loop

show B error B does not exist outside the loop

For most complicated operations and programs, we will need variables to store the intermediate values of the calculations. For example, to calculate the sum of all the numbers from 1 to 10 in a loop, we will need to store the intermediate calculations:

sum = 0

for (n from 1 to 10):

sum = sum + n

PROPOSED EXERCISES

Motivation: We want to calculate the first 10 elements of the Fibonacci sequence, where each element is the sum of the two previous ones. We know the first two, which are 1 and 1, but we need a loop to calculate the next two. How would it be programmed and how many variables would be necessary?

Grouping: Whole class

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: We will need at least three variables to be able to calculate the sequence.

- 57 -

Page 58: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

● Two variables, a and b, for storing the values of each step

● An auxiliary variable to calculate the next value without losing the previous ones.

At the end of each iteration of the loop, the variable b will contain the next value in the sequence, while a will remember the previous value of b.

Development: An operation that is often needed in programming but very few languages include is that of exchanging values. If we had two variables, A and B, and we wanted to exchange their values, we would need an auxiliary variable C. How should this operation be carried out?

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: The variable C takes the value of A and stores it. Thus, B can write its value to A and then retrieve the previous value of A from C. The process can also be done in the opposite direction: C copies B, A writes to B and A copies C.

or

- 58 -

Page 59: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Consolidation: We want our robot to start moving forward when we press one of the buttons and continue to move even if we have released the button. When we press it again, it should stop until we press it again. How can we program this?

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: We will need to create a variable that remembers whether the button has been pressed or not, so that we know whether to move forward. First of all, we will need to create this variable and give it an initial value, but it must not go inside the main loop! If we put it there, its value would be reset at every step and the robot would never be able to move. This time we will need to put it in the "Arduino configuration" block to make sure it is only given the initial value once.

Each time the button is pressed, this variable will change value to tell the program what to do. Although we could handle these values as we wish, as there are only two options (to advance or not to advance), the most efficient way is to create a variable of boolean type, that is to say, that can only be true or false. Inverting the value of a variable of this type is very simple: just tell it that its value is the opposite of the one it had before, using the "no" logic block.

- 59 -

Page 60: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.11 Functions

Specific objectives:

● Understanding what a function is and what it is used for● Learning to program and use functions● Identify in which situations it is necessary to use functions and functions with

returns

Specific content:

● Definition of function● Function calls● Functions with return

Definition of function

- 60 -

Page 61: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

A function is a set of statements that performs one or more tasks and is intended to be reused throughout a program. When a function terminates, it can return a value (functions with return) or return nothing (functions without return).

Making our robot dance

Let's imagine that we want our robot to do a dance consisting of a sequence of turns. Let's also suppose that we want our robot to do this dance in different parts of our program. With what we have seen so far, we would have to repeat the code of the dance in the parts we want to use it. This makes our program grow in size and becomes complicated to maintain, since when we want to modify the dance we will have to change the code in different parts of the program. Wouldn't it be easier to always use the same blocks?

Defining the function

To create the function, use a "for" block from the function section and fill the body of the function with blocks.

The function we have defined rotates the robot in one direction for two seconds, then in the opposite direction for two seconds and then stops the motors.

Calling the function

The blocks of a function are not executed unless you call the function. In the parts of our program where we want to make our robot dance, we will call the function. To do this, we must use the block with the name of the function that we have previously created.

- 61 -

Page 62: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

In this section of the program we turn on an LED and call our "dance" function if button A is pressed and turn off the LED and make our robot dance if button A is not pressed. As we can see, by using functions we have not had to repeat the code that makes the robot dance twice.

Functions with return

Return functions are the same as normal functions, but when they finish executing they return a value. Sometimes, when we call a function, we are not only interested in having it perform a series of tasks, but in obtaining the value resulting from a series of operations. It is in these cases that functions with return are useful.

Suppose, for example, that we want to calculate the modulus of a vector. The modulus is the distance of the oriented segment that defines the vector. If we have the x and y components of the vector, its modulus is √❑. Let's define a function that calculates the modulus of a vector assuming that we have defined two global variables x and y.

PROPOSED EXERCISES

Motivation: How could f(g(5)) be calculated if f(x) = x2 + 1 and g(z) = z + 2?

Grouping: Whole class

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: We will need two functions, one for f and one for g, and we will need to change the

- 62 -

Page 63: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

value of the global variables x and z carefully so that each function can access the correct value. Care must be taken with the priority of the operators.

Development: How would you program the function f(x) = g(h(2x)) + h(x+1), where g(a) = 1/(1+a) and h(b) = b2 + b?

Grouping: Small groups (2 to 4 students)

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: The solution would be as follows:

- 63 -

Page 64: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Consolidation: How would you write a function of x that calculates the sum of all odd numbers from 1 to x, if x is odd, and of all even numbers from 2 to x, if x is even? You will need to combine functions, variables, conditions and loops.

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: One possible solution is as follows:

- 64 -

Page 65: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

6.12 Following the line

Specific objectives:

● To understand the operation of a line-following robot.

● To know the different internal states of a line-following robot.

● Learn how to program a line-following robot

Specific content:

● Definition of line-following robot

● States of a line-following robot

● Programming a line-following robot

Definition of line-following robot

A line-following robot uses infrared sensors to detect whether the floor is white or black, so it can tell whether it is on a line or not. The robot proposed in this activity uses two infrared sensors to

- 65 -

Page 66: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

know not only if it is above a line, but also to know in which direction we should correct the robot's movement if it is going to leave the line.

States of a line-following robot

The following explains the possible states that our robot can be in depending on the sensor readings.

SensorsDesired action

Engines

left right left right

white white stop unemployed unemployed

white black turn right move forward

unemployed

black white turn left unemployed move forward

black black move forward move forward

move forward

Programming the robot in Blocky

To find out if the robot is above a black line, we need to read the status of the two infrared sensors. We will use the blocks "read line sensors" followed by "Reading on sensor located at..." to get the readings of the different infrared sensors. "blocks to get the readings from the different infrared sensors. The infrared sensors give a value between 2000 (black) and 0 (white).

To act on the motors we will use blocks prepared for this purpose. These are the blocks "Set motor speed" or "Change motor speed". In the following image we can see an example with these blocks.

- 66 -

Page 67: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Now we have to program the robot's movement to do its job, which is to follow a black line on a white background. Let's think about it a bit...

First state: both sensors see black

When the two sensors see black... what does it mean? It means that the robot is on the line, of course! What should we do in this case? We should move forward! To move forward we have to turn the two servos in the robot's forward direction.

Second state: both sensors see white

- 67 -

Page 68: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

When both sensors see white, it means that the robot has gone off the line and it is best to stop. Therefore, in this state, the two motors stop.

Third state: the right sensor sees black and the left sensor sees white.

In this case the robot is losing the orientation of the line and is leaving it to the left, i.e. we have to turn the robot to the right, right? Think about it, a two-wheeled robot can turn to the right if it turns its left wheel while keeping its right wheel stationary. So we know what we have to do in these cases.

Fourth state: the left sensor sees black and the right sensor sees white.

- 68 -

Page 69: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

In this case, as in the previous one, we also have to turn the robot to keep it on the line. However, now it is leaving the line to the right, so we have to turn the robot to the left. To do this, we move the right motor while keeping the left motor stationary.

From the four states we have seen, we can extract four simple rules that relate the sensors to the wheels and that will be very useful to make our programme in Blockly:

● When the right sensor sees black, the left wheel moves.

● When the right sensor sees white, the left wheel stops.

● When the left sensor sees black, the right wheel moves.

● When the left sensor sees white, the right wheel stops.

We define the variable "black" to set it as the threshold of clarity at which the robot is considered to be seeing a line. We also define the variable "vel_rotate" to set the speed at which the motors rotate.

Translating the above rules into the Blockly programme, we have:

- 69 -

Page 70: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

PROPOSED EXERCISES

Motivation: Could a line-following robot be programmed with only one sensor?

Grouping: Small groups (2 to 4 students)

Resources: Not required

Space: Classroom

Time: 10 minutes

Solution: Not efficiently. With a single sensor, the robot can only detect whether it sees a line or not, so it could only go as far as the first curve and get lost. However, with a colour-detecting sensor, a line could be painted to let it know where it is drifting, so it could correct its path.

- 70 -

Page 71: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Development: Copy the code shown to the graphical interface of the remote lab and run it. If it does not work correctly, what should be done?

Grouping: Whole class

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: The global variables black and rotation_speed control the operation of the robot. When running for the first time, they should be adjusted according to the characteristics of the machine: if the movement is unstable, rotation_speed should be reduced and if the line is not seen correctly, black should be modified.

Consolidation: How can we modify the code so that the robot tries to avoid the line instead of following it?

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: Simply reverse the rules of the programme. If a sensor sees black, it must stop the wheel on the opposite side to rotate in the opposite direction. In other words, in the program code, it is enough to modify the direction of the inequality: if the sensors' reading is less than black (i.e. it sees the line), the actions that would have been carried out if it did not see the line are carried out:

● When the right sensor sees white, the left wheel moves.

- 71 -

Page 72: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

● When the right sensor sees black, the left wheel stops. ● When the left sensor sees white, the right wheel moves.● When the left sensor sees black, the right wheel stops.

6.13 Getting out of the labyrinth

Specific objectives:

● Learn how to program a Robot that manages to get out of the labyrinth.● Understand what the left hand rule is all about.● Understand the structure of a Robot to fulfil the purpose of exiting the maze.

Specific content:

● Knowledge of the labyrinth● Programming a Robot that can get out of the labyrinth● The left hand rule

In this activity we are going to develop a robot that can find its way out of a maze. What would you do if you got lost in a maze?

Knowledge of the labyrinth

A simple way to find the exit is to use the "left hand rule" or the "right hand rule". This way of solving the maze consists of touching the left wall and, without taking your hand away, moving forward (it also works with the right wall).

To do this activity we are going to use what we have learnt in the previous activity of the line-follower. To do this, we are going to paint a maze made up of lines like the one shown in the figure.

- 72 -

Page 73: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Our robot will have two infrared sensors to follow the lines of the maze, as in the previous activity. But it will also have three more infrared sensors in the shape of a triangle to detect the intersections. In the figure we see a diagram with the position of the sensors.

The left hand rule can be translated into these simple rules with which we will program our robot:

1. If the robot can turn left, then it will turn left.

2. If not, if it can go straight, then it will go straight.

3. If not, if it can turn right, then it will turn right.

4. If you can't do any of the above, then turn around.

In the normal movement of the robot through the maze, the same code of the previous activity is used to follow the lines but, in addition, through the blocks "Read line sensors" and "Read sensor located at...", the robot must constantly consult its sensors to know if it is in an intersection. "the robot must constantly consult its sensors to know if it is at an intersection.

- 73 -

Page 74: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

We will now define a series of functions that will allow the robot to turn at intersections. We will use the line-following sensors to turn until the robot is positioned on its new path, whether it turns left or right. The following image shows the function for turning right. The function for turning left would be the same, but stopping the left motor and turning the right motor.

The turning function first moves the robot forward for a while, so that when it turns it can find the line corresponding to the intersection. It then starts to turn and distinguishes between two different states. First, it keeps turning until the line-following sensors detect that they have left the line. Then, in the next loop, it keeps the robot spinning until one of the line-following sensors detects the new line. Once the line is detected, it stops.

Now that we have defined the functions for spinning, let's see how the above rules translate to code in Blockly.

PROPOSED EXERCISES

Motivation: What would happen if we only used the "centre-left" and "centre-right" sensors?

- 74 -

Page 75: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Grouping: Small groups (2 to 4 students)

Resources: Not required

Space: Classroom

Time: 10 minutes

Solution: We would be in the case of the line-following robot. It could move through the maze in a straight line until it reached a corner or a dead end, but it could not turn at forks, so it could only reach the end of very simple mazes.

Development: Copy the code shown to the graphical interface of the remote lab and run it. If it does not work correctly, what should be done?

Grouping: Whole class

Resources: Computer with internet connection

Space: Remote laboratory

Time: 30 minutes

Solution: Again, the global variables black and forward_speed control the operation of the robot. When running for the first time, they should be adjusted according to the characteristics of the machine: if the movement is unstable, forward_speed should be reduced and if the line is not seen correctly, black should be modified.

Consolidation: How can we modify the code so that the robot always tries to go in a straight line and, if it has to turn, it tries to turn to the right first?

Grouping: Individual

Resources: Computer with internet connection

Space: Remote laboratory

Time: 20 minutes

Solution: Simply modify the program rules. First check whether the central sensor sees a line, then the right sensor, then the left sensor. The actions corresponding to each one are maintained:

1. If the robot can go straight, then it will go straight.2. If not, if it can turn right, then it will turn right.3. If not, if it can turn left, then it will turn left.

- 75 -

Page 76: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

4. If you can't do any of the above, then turn around.

7. Evaluation

The following evaluation criteria will be taken into account for the evaluation of the different activities that make up this Didactic Unit:

7.1 Assessment criteria

Activities Evaluation Criteria

Activity 1Introduction to Basic Robotics: Actuators and Sensors

Knows the internal components of the robot and their corresponding use

Know the differences between the two main types of robots

Activity 2Getting to know the Remote Lab interface

Knows and knows how to access the different sections of the Remote Laboratory website.

Activity 3What is an algorithm?

Develops skills for the creation of flowcharts

Organise activities according to the pattern of an algorithm.

Activity 4Our first programme in the Remote Lab: moving the robot

Identifies how the movement of the robot's wheels relates to the movement of the entire robot

Program the robot's movement

Activity 5Programming the LEDs

Learn about the characteristics of LED diodes

Programming with LED diodes using the visual programming language Blocky

Activity 6Loops

Understands the concept of control loops

Understands the structure of the control loop (while/for)

Detects the most favourable conditions for the use of a while loop or a for loop.

Activity 7 Understands the operation of an infrared sensor

- 76 -

Page 77: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Infrared sensors Program an infrared sensor

Activity 8Conditions

Understands in which situations it is necessary to use a conditional sentence

Logically organises a complex conditional statement

Activity 9Variables

Understand what a variable is at the programming level.

Program with variables

Activity 10Functions

Understand what a function is and what it is used for.

Program and use functions

Identifies in which situations it is necessary to use functions and functions with returns

Activity 11Follow the line

Understands the operation of a line-following robot

To know the different internal states of a line-following robot.

Program a line-following robot

Activity 12Emerging from the labyrinth

He manages to programme a robot that manages to get out of the labyrinth.

Understand what the left hand rule is all about.

Understand the structure of a robot to fulfil the purpose of exiting the maze.

7.2 Evaluation Procedures and Instruments

With reference to assessment procedures, in a school classroom it is recommended to carry out a continuous and summative assessment of all the activities and processes carried out in each teaching unit, understood as the individualised monitoring of the students and the assessment of their achievements in their learning process.

It would be interesting to carry out, in a continuous and systematic way, a direct observation of the students' contributions during the classes, of their participation in the classroom dynamics and of their perseverance in their tasks. Also, to analyse students' productions, oral exchanges with them, active participation, attitudes and interest in expanding their knowledge, using the techniques of self-evaluation, hetero-evaluation and co-evaluation.

- 77 -

Page 78: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

In terms of assessment tools, the following could be considered:

● Teacher's diary: where he/she will write down day by day how the activities, incidents, observations, etc. are being carried out.

● Student monitoring sheet: this is where absences, absences from work, etc. will be recorded.

● Individual and group work: It should be borne in mind that computer work has a strong cooperative component that can be used to develop social and civic competence.

In team work, the degree of coordination followed in the distribution of tasks, degree of participation, integration in different groups, collaboration and responsibility shown in team work and the demonstration of attitudes that favour collective work will be taken into account.

● Rubrics: These scoring guides will be used to assess students' work, describing the specific characteristics of a product, project or task at various levels of performance, in order to clarify what is expected of their learning, to assess their performance and to facilitate feedback, as well as to facilitate self- and co-assessment.

Below is a rubric that could help in the evaluation of the team work done in Robot programming activities in this didactic unit:

Evaluation Category (Excellent) (Good) (Deficient)

1(Insufficient)

Teamwork

Always listens to, shares and

supports the efforts of

colleagues. Try to maintain the unity of the

group members.

Usually listens to, shares and

supports the efforts of peers. Does not cause problems in the

group

They sometimes listen to, share

and support the efforts of their

peers.

Never listens to, shares and/or supports the efforts of colleagues

Contributions

Always provides useful ideas when

participating in team and class discussion. Is a definite leader

who contributes a lot of effort

As a rule, it provides useful

ideas when participating in team and class discussion. Is a

strong member of the group who

strives to

Sometimes provides useful

ideas when participating in team and class

discussion.

Rarely provides useful ideas when

participating in team and class discussion.

- 78 -

Page 79: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

Attention to work

Stays focused on the work that

needs to be done. Very self-directed

Most of the time it focuses on the work that needs

to be done.

Sometimes it focuses on the

work that needs to be done.

Never focus on the work that needs to be

done. Let others do their work

Attitude

Never publicly criticises the project or the

work of others. Always has a

positive attitude towards the work

Rarely publicly criticises the project or the

work of others. Often has a

positive attitude towards the

work.

Occasionally criticises the work

of other group members. Has a positive attitude towards work

Often criticises the work of others. Rarely has a positive attitude

towards work.

Troubleshooting

Seeks and suggests

solutions to problems

Refines solutions suggested by

others

Does not suggest or refine

solutions, but is willing to discuss

solutions proposed by

peers

Does not try to solve problems or help

colleagues to solve them. Let them do

their job

- Specific self-assessment work or specific synthesis work, where students can appreciate elements such as what they have learnt in the development of the didactic unit.

8. Conclusion

This Teaching Unit aims to teach the basic fundamentals of programming through educational robotics. Based on the current Spanish educational legislation, a series of learning objectives and contents have been set out, in order to reach the evaluation criteria coherently, following a methodology and a set of practical and functional activities with the aim of bringing the contents closer to the students in different subjects of the school curriculum, such as: Science, Technology, Engineering and Mathematics (STEM) as they are more closely related to the syllabus. It is also susceptible to work in other educational areas due to its transversal component, corresponding to Compulsory Secondary Education and Baccalaureate.

Programming is, nowadays, a multidisciplinary tool that can help students in a wide variety of situations, allowing them to tackle in a structured way the resolution of problems that not only have to do with Computer Science, but also with other types of fields. For its part, robotics is a cross-cutting subject that encompasses subjects related to electronics, mechanics and computer science, among others, and which can be used in other educational areas where it can bring benefits.

- 79 -

Page 80: Title of the teaching unit · Web viewRev: 1.0 (October/2016) Author: LabsLand Experimentia S.L. (contact@labsland.com) Table of contents 1. Title of the teaching unit 4 2. Substantiation

This activity has been designed for use with the Labsland Arduino Robot Lab - Visual. You can find more labs and activities at: https://labsland.com

9. Bibliography and webography

BOOKS

One author:

Antúnez, S. Del proyecto educativo a la programación de aula. Madrid, 2010 Editorial Graó

Craig, J. J. Introduction to robotics: mechanics and control. Upper Saddle River, 2005, Pearson Prentice Hall, Vol. 3, pp. 48-70.

Stroustrup, B. The C++ Programming Language, Madrid, 1998, Addison Wesley

Two or more authors:

Margaret A. E. y Stroustrup, B. The Annotated C++ Reference Manual, 1990, Addison-Wesley

MAGAZINES

Antonio, C. P. et al. Remote experiments and 3D virtual world in education. Ponta Delgada, 2015, 3rd Experiment Int. Conf. , pp. 65-70.

Carro, G. et al. The color of the light: A remote laboratory that uses a smart device that connects teachers and students. Istanbul, 2014, IEEE Global Engineering Education Conference (EDUCON), pp. 854-860.

Islamgozhayev, T. U. et al, IICT-bot: Educational robotic platform using omni-directional wheels with open source code and architecture, Omsk, 2015, Int. Siberian Conf. Control and Communications (SIBCON), pp. 1-3.

Merrill, M. D. First principles of instruction. Educational Technology Research and Development, 2002, Vol. 50 (3), pp. 43-59.

Peng, J., Tan, W. y Liu, G. Virtual Experiment in Distance Education: Based on 3D Virtual Learning Environment, Wuhan, 2015, Int. Conf. Educational Innovation through Technology (EITT), pp. 81-84.

Roscoe, J. F., Fearn, S., y Posey, E. Teaching Computational Thinking by Playing Games and Building Robots, Nottingham, 2014, Int. Conf. Interactive Technologies and Games (iTAG), pp. 9-12.

ONLINE Bitbloq programming courses for DIWO, by BQ. Retrieved from http://diwo.bq.com/course/aprende-robotica-y-programacion-con-bitbloq-2

- 80 -