Topic outline

  • INTRODUCTION



  • ACTIVITY DESCRIPTION

    Using MBOT robot mounted in the first experiment, students analyse some fundamental arguments of computer programming. Easy applications will be made, introducing 5 programming control structures.


    The purpose of this module is to solve basic problems and to develop basic skills of programming. At the end of the experiment, students don't check complex applications but they test, almost singularly, control structures and the basic potential of the programming environment. Simple basic exercises to get familiar with programming.


    Below you can find few simple programs using ultrasonic sensor

  • EXERCISE 1 - CALCULATING DISTANCES

    Know the distance through the Ultrasound sensor.




    Discover, that panda show you the distance when you press "d-key", after that it doesn't change.


    Make modyfication:



    Now after pressing "d-key", you can see that number is changing when you move hand in front of sensor.


    When you use "forever loop" the robot reads from sensor constantly

  • EXERCISE 2 - IF CONDITION

    Program starts when you press space key.


    Set led on board to green colour.


    If ultrasonic sensor will see something in the distance smaller then 30, the colour or led change to red.


    Start the program several times. Each time place the robot in different distance from the wall (less or more than 30).




  • EXERCISE 3 - IF... ELSE CONDITION

    Before you press k-key place the robot in different distance from the wall. Use program several times. Can you see green color? Add the wait block before if and try again.





  • EXERCISE 4 - LOOP FOREVER

    Exercise 2 and 3 teach you that program work only one time. In exercise one you used forever loop, and panda shows the readings up to date. So add this loop. This time leds changes colour depending of distance.





  • EXERCISE 5 - LOOP FOREVER UNTIL

    The program check condition. If it is false the robot make instruction in loop. When the condition became true the program make the next instruction after the loop.






    The robot runs when it is far away from the wall - the condition is false. But, when robot gets closer to wall, the condition become true and the robot stops.