The UCL Engduino is a small electronics board designed to help people understand coding practice and create programs that have visible rewards like LEDs lighting up or gaining information from sensors. It can be plugged into a computer through a USB socket and data can be sent from the Engduino to and from the computer, and if a Bluetooth module is connected to the device, it can work with programs written on smartphones and tablet devices. For the purposes of the exercises listed, we are going to use the Engduino Simulator in TouchDevelop to show the outputs of the programs written.

The latest version of the Engduino (version 3) has many sensors that students can learn to use in order to make interesting programs, and the following are useable within the standard TouchDevelop platform:



Tutorial

We suggest you follow the links below to better understand the basics of how to implement these sensors in your program and to get some insight into the sensors.



Basic commands

The basic commands that might be helpful when creating scripts that use sensors:

  1. Adding the Engduino Temperature Sensor

    var x := engduino -> temperature

    • var x - creates a variable called x so that the sensor reading can be saved. The data type is number which has decimal places called float or double
    • Engduino -> temperature - gets the temperature readout from the Engduino. The readings can vary a lot as the simulator returns random values but it should be around 250-300.

  2. Adding the Engduino Accelerometer

    var y := engduino -> accelerometer

    • Engduino -> accelerometer - gets the vector of acceleration from the Engduino

  3. Checking whether the Engduino button has is being pressed / has been pressed

    var z := engduino -> button pressed

    • z is a Boolean variable that holds the value of 'true' or 'false' based on whether the button is being pressed down. engduino -> button pressed will only return a true value if the button is being held down.
    • This is different from the next line of code, which will check if a button has been pressed at all since the program has been run.

    var a := engduino -> button was pressed

    • a is a Boolean variable that holds the value of 'true' or 'false' depending on whether the button has been pressed before this line of code is written.
    • This simplifies checking whether the button has been pressed as you don’t have to write a loop containing a check of whether the button is being pressed


Useful Notes:

You can combine the sensor readings with the tutorials used previously, in order to create a program that will keep taking in readings and output them as a graph or can change the LEDs based on whether the sensor values are too high or too low.


Exercises:

Using the information you have just learned, combined with knowledge from the previous chapters, complete the following exercises.

  1. Create a script that takes 10 temperature sensor readings and prints out the average, without using the avg command.
  2. Create a script that will turn on all the Engduino LEDs if the button is pressed.
  3. Drawing from Questions 1 and 2, create a script that will start when the button is pressed and will change the colour of the LEDs to red, if the temperature sensor reads a value above 295 and will change the colour of the LEDs to blue if the temperature sensor reads below 295.


Don't stop here! Experiment with the commands you have learned and create scripts of your own.



PREVIOUS LESSON

BACK TO INDEX