{"id":677,"date":"2021-11-10T17:07:20","date_gmt":"2021-11-10T15:07:20","guid":{"rendered":"https:\/\/med.upc.edu\/team4-2021\/?page_id=677"},"modified":"2022-09-05T12:19:56","modified_gmt":"2022-09-05T11:19:56","slug":"activities","status":"publish","type":"page","link":"https:\/\/med.upc.edu\/team4-2021\/activities\/","title":{"rendered":"Activity 15"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>CONTROLLING THE BUTTON AND LEDS <\/strong><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>(Extra activity performed by Francesc Capdevila)<\/strong> <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Within the transversal project there are two exercises that we have decided to carry out due to their special interest. We have decided to install the Raspberry 4 in our drone and carry out activity 15, which consists of activating some peripherals of the raspberry that can inform us of the status of the internet connection or, for example, the status of the battery or power supply.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-1024x768.jpg\" alt=\"\" class=\"wp-image-1064\" width=\"641\" height=\"481\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-1024x768.jpg 1024w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-300x225.jpg 300w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-768x576.jpg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-1536x1152.jpg 1536w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/20220505_130011-2048x1536.jpg 2048w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">I forgot to connect ground wires&#8230;.!!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-576x1024.jpeg\" alt=\"\" class=\"wp-image-1094\" width=\"378\" height=\"672\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-576x1024.jpeg 576w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-169x300.jpeg 169w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-768x1365.jpeg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-864x1536.jpeg 864w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-1152x2048.jpeg 1152w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/rpi-ground-wires-scaled.jpeg 1440w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><figcaption>Dont forget the ground wires!!<\/figcaption><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">LEDS<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" class=\"wp-image-1079\" style=\"width: 150px\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/LEDS-1.mp4\" alt=\"\">In this first test I have tested that all the LEDs work, however I have finally decided that for the final master project I am only interested in knowing if the RPi has power supply. So in the script I have decided to leave only the green color at 255.<img decoding=\"async\" class=\"wp-image-1077\" style=\"width: 150px\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/LEDS.mp4\" alt=\"\"><\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video controls src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/vid-20220517-wa0009_9Nio09Lf-1.mp4\"><\/video><figcaption>@Francesc Sancho Capdevila, RPi LED test.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"352\" style=\"aspect-ratio: 640 \/ 352;\" width=\"640\" controls src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/led-verda-1.mp4\"><\/video><figcaption>Rpi with the green light online for power supply @Francesc Sancho Capdevila<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thonny is already installed on the SD, and we have an ex1.py file on the desktop.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The file contains a small script that simply lights up the 5 leds of the raspby in green.The way to run this script every time we turn on the computer is to do a cron job. Cron is a daemon that periodically executes all commands inside the crontab file.When doing <em>crontab -e<\/em> , it asks us to choose the text editor we like best and then lets us modify the file. We add the order:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>reboot sudo python3 \/home\/pi\/Desktop\/ex1.py<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SCRIPT<\/h2>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<blockquote class=\"wp-block-quote is-style-plain is-layout-flow wp-block-quote-is-layout-flow\" style=\"font-style:normal;font-weight:200\"><p><em>from gpiozero import Button<\/em><\/p><p><em>from signal import pause<\/em><\/p><p><em>import board<\/em><\/p><p><em>import neopixel<\/em><\/p><p><em>import time<\/em><\/p><p><em>from gpiozero import LED<\/em><\/p><p><em>def lights() :<\/em><\/p><p>           <em>for i in range(0, 5) :<\/em><\/p><p><strong>#remember RED, GREEN; BLUE, and 255 max value, we can choose a lower one.<\/strong>(0, 255, 0)<\/p><p>                <em> pixels [i] = (0, 255, 0)<\/em><\/p><p><em>pixels = neopixel.NeoPixel (board.D18, 5)<\/em><\/p><p><em>lights ()<\/em><\/p><\/blockquote>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Which means that every time there is a reboot it runs the script, that is, when it is turned on.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>Cron is a software utility that allows us to schedule tasks on Unix-like systems. The name is derived from the Greek word &#8220;Chronos&#8221;, which means &#8220;time&#8221;.Tasks in Cron are defined in a crontab, which is a text file that contains the commands to run. <a href=\"https:\/\/pypi.python.org\/pypi\/python-crontab.\">https:\/\/pypi.python.org<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/pypi.python.org\/pypi\/python-crontab.\" target=\"_blank\">\/pypi\/python-crontab.<\/a><\/em><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Final Setup<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-695x1024.jpeg\" alt=\"\" class=\"wp-image-1095\" width=\"433\" height=\"637\" srcset=\"https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-695x1024.jpeg 695w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-204x300.jpeg 204w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-768x1131.jpeg 768w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-1043x1536.jpeg 1043w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-1391x2048.jpeg 1391w, https:\/\/med.upc.edu\/team4-2021\/wp-content\/uploads\/sites\/5\/2022\/05\/processed-c1cd6826-7291-4334-9a44-3faae03e8ca9_8XvmgTTz17161-scaled.jpeg 1739w\" sizes=\"(max-width: 433px) 100vw, 433px\" \/><figcaption>@Francesc Sancho Capdevila<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CONTROLLING THE BUTTON AND LEDS (Extra activity performed by Francesc Capdevila) Within the transversal project there are two exercises that we have decided to carry out due to their special interest. We have decided to install the Raspberry 4 in our drone and carry out activity 15, which consists of activating some peripherals of the [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-677","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/comments?post=677"}],"version-history":[{"count":18,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/677\/revisions"}],"predecessor-version":[{"id":1142,"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/pages\/677\/revisions\/1142"}],"wp:attachment":[{"href":"https:\/\/med.upc.edu\/team4-2021\/wp-json\/wp\/v2\/media?parent=677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}