{"id":11123,"date":"2025-10-05T21:14:46","date_gmt":"2025-10-05T20:14:46","guid":{"rendered":"https:\/\/dronesonen.usn.no\/?p=11123"},"modified":"2025-10-11T17:45:00","modified_gmt":"2025-10-11T16:45:00","slug":"autobalance-week-6","status":"publish","type":"post","link":"https:\/\/dronesonen.usn.no\/?p=11123","title":{"rendered":"AutoBalance: Week 6"},"content":{"rendered":"\n<p><strong>Meron:<\/strong><br>This week I focused on redesigning several parts after discovering that certain components did not fit properly in reality and following feedback from Richard, I paid special attention to the front wheel design which required adjustments. In addition, some parts were broken during testing which made it necessary to redraw and improve the design to ensure better durability. Alongside this work I also developed a concept for our final motorbike design and presented a motivational reference image to the teacher which was approved. As result we now plan to create two versions, one prototype that will be 3 D printed and physically and a more detailed final design model that can be delivered as a complete project.&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"533\" data-id=\"11127\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-4.png\" alt=\"\" class=\"wp-image-11127\" style=\"width:318px;height:auto\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-4.png 400w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-4-225x300.png 225w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"393\" height=\"524\" data-id=\"11129\" src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-6.png\" alt=\"\" class=\"wp-image-11129\" style=\"width:299px;height:auto\" srcset=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-6.png 393w, https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/image-6-225x300.png 225w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Salim:<\/strong><br>I have been working on controlling a motorcycle using the BitPlayer controller. I Worked with buttons A and B on the controller, where A moves the motorcycle forward and F is shown on the display and B moves it backward, B is shown in the display. The selected direction is displayed on the micro:bit\u2019s screen. <br>We used radio communication to establish the connection between the micro:bits.<br><br>I experimented with several additional functions, but they were not all successful I plan to lokk futher into these further later on. <br><br>The default movement mode was defined as mode = 0, where button control (A and B) is active. When button C is pressed, the system switches to joystick mode, where movement is controlled using the joystick\u2019s Y and \u2013Y axes for forward and backward motion. Pressing C again returns the system to the default button mode (mode = 0). <br><br>When button D is pressed, the controller switches to tilt mode, which uses the micro:bit\u2019s accelerometer and displays arrows on the LED screen to indicate direction. This mode was defined as mode = 2. Buttons J and T represent these modes on the controller. <br><br>The code and demonstration video are provided below.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls src=\"https:\/\/dronesonen.usn.no\/wp-content\/uploads\/2025\/10\/IMG_5777.mov\"><\/video><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>def my_function():\n    pass\njoystickbit.on_button_event(joystickbit.JoystickBitPin.P14,\n    joystickbit.ButtonType.DOWN,\n    my_function)\ndef my_function2():\n    pass\njoystickbit.on_button_event(joystickbit.JoystickBitPin.P13,\n    joystickbit.ButtonType.DOWN,\n    my_function2)\n\nyy = 0\nxx = 0\nY = 0\nradio.set_group(67)\nmode = 0\nlastState = \"STOP\"\nbasic.show_string(\"Hello!\")\n\ndef on_forever():\n    global Y, lastState, xx, yy\n    if mode == 1:\n        Y = pins.analog_read_pin(AnalogReadWritePin.P2)\n        if Y &lt; 300:\n            radio.send_string(\"F\")\n            basic.show_string(\"F\")\n            lastState = \"FORWARD\"\n        elif Y &gt; 700:\n            radio.send_string(\"B\")\n            basic.show_string(\"B\")\n            lastState = \"BACKWARDS\"\n        else:\n            radio.send_string(\"S\")\n            basic.show_string(\"S\")\n            lastState = \"STOP\"\n        basic.pause(100)\nif mode == 2:\n        xx = input.acceleration(Dimension.X)\n        yy = input.acceleration(Dimension.Y)\n        if yy &lt; -300:\n            radio.send_string(\"F\")\n            basic.show_leds(\"\"\"\n                . . # . .\n                . # # # .\n                # # # # #\n                . . # . .\n                . . # . .\n                \"\"\")\n        elif yy &gt; 300:\n            radio.send_string(\"B\")\n            basic.show_leds(\"\"\"\n                . . # . .\n                . . # . .\n                # # # # #\n                . # # # .\n                . . # . .\n                \"\"\")\n        elif xx &lt; -300:\n            basic.show_leds(\"\"\"\n                . . # . .\n                . # # . .\n                # # # # #\n                . # # . .\n                . . # . .\n                \"\"\")\n        elif xx &gt; 300:\n            basic.show_leds(\"\"\"\n                . . # . .\n                . . # # .\n                # # # # #\n                . . # # .\n                . . # . .\n                \"\"\")\n        else:\n            radio.send_string(\"S\")\n            basic.show_leds(\"\"\"\n                . . . . .\n                . . . . .\n                # # # # #\n                . . . . .\n                . . . . .\n                \"\"\")\n        basic.pause(100)\nbasic.forever(on_forever)\n\ndef on_forever2():\n    global lastState\n    if mode == 0:\n        if input.button_is_pressed(Button.A):\n            radio.send_string(\"F\")\n            basic.show_string(\"F\")\n            lastState = \"FORWARD\"\n        elif input.button_is_pressed(Button.B):\n            radio.send_string(\"B\")\n            basic.show_string(\"B\")\n            lastState = \"BACKWARDS\"\n        else:\n            radio.send_string(\"S\")\n            basic.show_string(\"S\")\n            lastState = \"STOP\"\n    basic.pause(100)\nbasic.forever(on_forever2)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Mohammed A:<\/strong><br><\/p>\n\n\n\n<p>This week we tested the motorcycle prototype that meron designed. During the test, we identified several issues, the most critical being that the front axle did not fit properly. As a result, we asked Meron to redesign the part with corrected dimensions. We then consulted Richard to obtain new axles for the updated design.&nbsp;<\/p>\n\n\n\n<p>Meron adjusted the CAD model to the correct diameter, and we proceeded to 3D print the new components. During assembly, we discovered that the rear wheel had an oversized hole for the axle, which required printing a revised version. Additionally, we produced a wheel to fit the motor shaft. &nbsp;<\/p>\n\n\n\n<p>On the day the components were completed, just before our meeting, we made further adjustments to the system. Specifically, the motor was repositioned closer to the motorcycle frame in order to prevent the weight from shifting backwards. Another issue we observed was that the plastic mount holding the motor generated friction with the ground. By slightly repositioning the motor, this problem was resolved and the system functioned as intended.&nbsp;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Muhammed \u00d8:<\/strong><br>This week i worked on the controll system for the motorcycle, to integrate the driving elements with the controller. I synchronized these functions with the radio message recived from the controller. When the controller sends command such as \u201cF\u201d for forward or \u201cB\u201d for backward, the system interprets them and drives the motor accordingly.&nbsp;<\/p>\n\n\n\n<p>This is the code that was used:\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def motor_forward():\n    pins.digital_write_pin(DigitalPin.P8, 1)# ENA HIGH\n    pins.digital_write_pin(DigitalPin.P0, 1)# IN1 HIGH\n    pins.digital_write_pin(DigitalPin.P1, 0)# IN2 LOW\ndef motor_backward():\n    pins.digital_write_pin(DigitalPin.P8, 1)\n    # ENA HIGH\n    pins.digital_write_pin(DigitalPin.P0, 0)\n    # IN1 LOW\n    pins.digital_write_pin(DigitalPin.P1, 1)\nIN2 HIGH\ndef motor_stop():\n    pins.digital_write_pin(DigitalPin.P8, 0)\n    # ENA LOW\n    pins.digital_write_pin(DigitalPin.P0, 0)\n    pins.digital_write_pin(DigitalPin.P1, 0)\nmessage = \"\"\nSett opp radio\nradio.set_group(67)\n\ndef on_forever():\n    global message\n    message = radio.receive_string()\n    if message == \"F\":\n        basic.show_string(\"F\")\n        motor_forward()\n    elif message == \"B\":\n        basic.show_string(\"B\")\n        motor_backward()\n    else:\n        motor_stop()\n        basic.show_string(\"S\")\nbasic.forever(on_forever)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Meron:This week I focused on redesigning several parts after discovering that certain components did not fit properly in reality and following feedback from Richard, I paid special attention to the front wheel design which required adjustments. In addition, some parts were broken during testing which made it necessary to redraw and improve the design to [&hellip;]<\/p>\n","protected":false},"author":112,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11123","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/11123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11123"}],"version-history":[{"count":4,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/11123\/revisions"}],"predecessor-version":[{"id":11362,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=\/wp\/v2\/posts\/11123\/revisions\/11362"}],"wp:attachment":[{"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dronesonen.usn.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}