PROGRAMMING SCHOOL
Programming micro:bit in MakeCode
1. STEPPER MOTOR (BIPOLAR) - HALFSTEP13. SERVO MOTOR
2. STEPPER MOTOR (BIPOLAR) - STEP14. MOTOR - ROTATION CONTROL WITH BUTTONS "A" AND "B"
3. VALUE DISPLAY (IO F5 + micro:bit AD)15. COLOR SENZOR (FischerTechnik) - COLOR recognition
4. ULTRASONIC sensor - we create music16. LIGHT CONTROLL - POTO sensor (ANALOGUE) - RECOGNIZING BLACK LINE
5. ULTRASOUND SENSOR (3.3V) - random car control17. LIGHT CONNTROL - POTO sensor (ANALOGUE)
6. ENCODER MOTOR - COUNTER CONTROL18. LIGHT CONTROLL - MAGNETIC sensor (DIGITALLY) 4
7. IR sensor19. LIGHT CONTROLL - POTO sensor (DIGITALLY) 3
8. 4 x DC motor control - anlogue - digitaly20. LIGHT CONTROLL - POTO sensor (DIGITALLY) 2
9. 2 x DC motor control - anlogue21. LIGHT CONTROLL - PUSH BUTTON (DIGITALLY)
10. ULTRASONIC SENSOR DISTANCE MEASUREMENT - value display22. TWO LIGHTS CONTROLL WITH BUTTONS A AND B
11. ULTRASONIC SENSOR DISTANCE MEASUREMENT - View as GRAPH23. TWO LIGHTS CONTROLL
12. Controling LEDs with Potentiometer24. LIGHT / LED CONTROLL

STEPPER MOTOR (BIPOLAR) - HALFSTEPTOP
spajanje24_mb.jpg

The micro: bit can control the operation of the stepper motor. This example shows the control of a stepper motor in one direction by a shift of HALF STEPS. To work in the opposite direction, the order should be reversed. By changing the value of the SPEED variable, we change the engine speed - turning the engine by one step. The motor in the example has a peak consumption of 600 mA, so the driver chips heat up a lot during longer operation. For longer operation, it would be necessary to select motors that have lower consumption or replace the L293D drivers with a version of the L293B that supports consumption up to 1000 mA per output. We use a 5V adapter for power supply.

STEPPER MOTOR (BIPOLAR) - STEPTOP
spajanje23_mb.jpg

The micro: bit can control the operation of the stepper motor. This example shows a stepper motor control in one direction by a STEP offset. To work in the opposite direction, the order should be reversed. By changing the value of the SPEED variable, we change the engine speed - turning the engine by one step. The motor in the example has a peak consumption of 600 mA, so the driver chips heat up a lot during longer operation. For longer operation, it would be necessary to select motors that have lower consumption or replace the L293D drivers with a version of the L293B that supports consumption up to 1000 mA per output. We use a 5V adapter for power supply.

VALUE DISPLAY (IO F5 + micro:bit AD)TOP
spajanje22_mb.jpg

We can use the micro:bit AD interface to display the values when creating the program. We connect the interface via I2C communication and we can use all the functions built into the micro:bit AD interface. We can display data in text or graphic form. In this example, we use an ultrasonic sensor.

ULTRASONIC sensor - we create musicTOP
spajanje21_mb.jpg

Music using an ultrasonic sensor. Another one can be added to control the volume. With a little play, different sound effects can be created.

ULTRASOUND SENSOR (3.3V) - random car controlTOP
spajanje20_mb.jpg

Connect the ULTRASONIC sensor to the 3.3V supply (red and green). Connect the signal wires to the input P0 (blue) and P3 (black). Connect the right motor to the motor outputs M1 (P15 and P16), and the left at the motor outputs M2 (P13 and P14). ADD package "SONAR".

ENCODER MOTOR - COUNTER CONTROLTOP
spajanje19_mb.jpg

Connect encoder motor to OUTPUTS P15 and P16. Counter supply ( green and red wire ) connect to 5V output. Signal wire connect to INPUT P1.

IR sensorTOP
spajanje18_mb.jpg

We can use it to detect a black line in a vehicle model that follows a black line, or we can use it as a white obstacle sensor (distance sensor). The Fischertechnik IR sensor consists of two sensors (blue wires) that detect a white (bright) surface.

4 x DC motor control - anlogue - digitalyTOP
spajanje17_mb.jpg

Speed control of four DC motors. Simulation of analog control via the "write digital" command. MakeCode has a limit of max. three outputs that can control analog. This is a method that works similar to the PWM control (write analog).

2 x DC motor control - anlogueTOP
spajanje16_mb.jpg

DC motor speed control via write analog command. The limit is a maximum of three DC motors.

ULTRASONIC SENSOR DISTANCE MEASUREMENT - value displayTOP
spajanje15_mb.jpg

Measuring distance by ultrasonic sensor with results display in the form of values, on the micro: bit screen. You need package "SONAR".

ULTRASONIC SENSOR DISTANCE MEASUREMENT - View as GRAPHTOP
spajanje14_mb.jpg

Ultrasound sensor distance measurement with bar graph display on micro:bits screen. You need package "SONAR".

Controling LEDs with PotentiometerTOP
spajanje13_mb.jpg

Turning the potentiometer turns on the LEDs. The potentiometer is connected to INPUT P0 and reads analogously. The interface is powered by a universal 5V adapter.

SERVO MOTORTOP
spajanje12_mb.jpg

Connect servo (4.8 - 6V) to 5V supply and signal wire to INPUT P0.

MOTOR - ROTATION CONTROL WITH BUTTONS "A" AND "B"TOP
spajanje11_mb.jpg

Connect motor on OUTPUTS 1 i 2 (P16 i P15).

COLOR SENZOR (FischerTechnik) - COLOR recognitionTOP
spajanje10_mb.jpg

Connect the RED light to OUT 1 (P16), GREEN to OUTPUT 2 (P15), ON to OUT 3 (P14), and COLOR sensor to input 1 (P1). Connect the sensor power to the OUTPUT P8. Add "digital write pin P8 to 1" on start after "led enable". Use the analogue reading of the input value in the program. Set the program's operation according to the Input Readings for color matching.

LIGHT CONTROLL - POTO sensor (ANALOGUE) - RECOGNIZING BLACK LINETOP
spajanje09_mb.jpg

Connect the RED lamp to OUT 1 (P16), and the PHOTO sensor to input 1 (P1). Use the analogue reading of the input value in the program. Base should be illuminated. You can do a test by turning the sensor towards the light.

LIGHT CONNTROL - POTO sensor (ANALOGUE)TOP
spajanje08_mb.jpg

Connect the RED lamp to OUT 1 (P16), and the PHOTO sensor to input 1 (P1). Use the analogue reading of the input value in the program.

LIGHT CONTROLL - MAGNETIC sensor (DIGITALLY) 4TOP
spajanje07_mb.jpg

Connect the RED lamp to OUT 1 (P16), and the PHOTO sensor to input 1 (P1). Use the digital reading.

LIGHT CONTROLL - POTO sensor (DIGITALLY) 3TOP
spajanje06_mb.jpg

Connect the RED lamp to OUT 1 (P16), and the PHOTO sensor to input 1 (P1). Use the digital reading.

LIGHT CONTROLL - POTO sensor (DIGITALLY) 2TOP
spajanje05_mb.jpg

Connect the RED lamp to OUT 1 (P16), and the PHOTO sensor to input 1 (P1). Use the digital reading.

LIGHT CONTROLL - PUSH BUTTON (DIGITALLY)TOP
spajanje04_mb.jpg

Connect the RED lamp to OUT 1 (P16), and PUSH BUTTON to the input 1 (P1).

TWO LIGHTS CONTROLL WITH BUTTONS A AND BTOP
spajanje03_mb.jpg

Connect the RED lamp to OUT 1 (P16), and GREEN to OUTPUT 2 (P15).

TWO LIGHTS CONTROLLTOP
spajanje02_mb.jpg

Connect the RED lamp to OUT 1 (P16), and GREEN to OUTPUT 2 (P15).

LIGHT / LED CONTROLLTOP
spajanje01_mb.jpg

Connect the light to OUT 1 (P16).