{"id":29329,"date":"2022-08-22T21:33:36","date_gmt":"2022-08-23T04:33:36","guid":{"rendered":"https:\/\/digilent.com\/blog\/?p=29329"},"modified":"2022-08-22T21:33:36","modified_gmt":"2022-08-23T04:33:36","slug":"build-a-smart-lamp-using-an-analog-discovery-pro-adp3450-part-3","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/build-a-smart-lamp-using-an-analog-discovery-pro-adp3450-part-3\/","title":{"rendered":"Build a Smart Lamp Using an Analog Discovery Pro ADP3450 \u2013 Part 3"},"content":{"rendered":"<p>In this third issue of our four-part blog post series covering the creation of a smart LED-lamp, we are designing the Android app controlling brightness and state of the LED. For this, we use an <a href=\"https:\/\/digilent.com\/shop\/analog-discovery-pro-3000-series-portable-high-resolution-mixed-signal-oscilloscopes\/\">Analog Discovery Pro ADP3450<\/a> from Digilent, running in Linux Mode. During the first installment &lt;INSERT LINK TO FIRST PART HERE&gt;, we wrote the hardware abstraction layer (HAL) routines for the <a href=\"https:\/\/digilent.com\/reference\/software\/waveforms\/waveforms-sdk\/start\">WaveForms SDK<\/a>. In the <a href=\"https:\/\/digilent.com\/blog\/build-a-smart-lamp-using-an-analog-discovery-pro-adp3450-part-2\/\">second part<\/a> , we created the Software functions for the two Pmods we use for our project: the <a href=\"https:\/\/digilent.com\/shop\/pmod-als-ambient-light-sensor\/\">Pmod ALS<\/a>, measuring the intensity of the ambient light, and the <a href=\"https:\/\/digilent.com\/shop\/pmod-ble-bluetooth-low-energy-interface\/\">Pmod BLE<\/a>, which receives the settings from the smartphone app and transmits them to the ADP3450. There, we also tested the connections between the Pmods and the ADP3450.<\/p>\n<p>First, we are going to create the app and then build the LED-driver hardware and the charging circuit for the battery.<\/p>\n<h2>Designing the Android App<\/h2>\n<p>For the smartphone app, we use the <a href=\"https:\/\/appinventor.mit.edu\/\">MIT App Inventor<\/a>. You will need a Google account to log in. If you don\u2019t have one or if you would rather not use it for this exercise, <a href=\"http:\/\/code.appinventor.mit.edu\/\">you can access it anonymously from this page<\/a>. Make a note of the re-enter code displayed, so you can continue your work at a later stage.<\/p>\n<p><a href=\"#_ftnref1\" name=\"_ftn1\"><span><\/span><\/a><span><a href=\"http:\/\/code.appinventor.mit.edu\/#-1\"><\/a><\/span><\/p>\n<p>The first step is to create the user interface. You can do that from scratch, but you can also download our <a href=\"https:\/\/digilent.com\/reference\/_media\/test-and-measurement\/analog-discovery-pro-3x50\/digilent_lamp_controller_project.zip\">pre-built project file<\/a> and import it. If you want to avoid bothering with the creation of the app at all, you can also <a href=\"https:\/\/digilent.com\/reference\/_media\/test-and-measurement\/analog-discovery-pro-3x50\/digilent_lamp_controller_apk.zip\">download and install the final application<\/a>. As a shortcut, scan the QR code below with your phone.<\/p>\n<p>Our application needs two switches for turning the lamp on and off, and setting the intensity to <em>auto<\/em>. It also requires three sliders for the three colors red, green, and blue. Done with that, go to the <em>Extension<\/em> menu on the left and place the <em>Bluetooth LE<\/em> component on the screen of your virtual phone.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.digilent.com\/blog\/wp-content\/uploads\/2022\/08\/Virtual-Phone.png\" alt=\"\" width=\"1500\" height=\"790\" class=\"aligncenter size-full wp-image-29331\" data-wp-pid=\"29331\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/Virtual-Phone.png 1500w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/Virtual-Phone-600x316.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/Virtual-Phone-1024x539.png 1024w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/p>\n<p>Now enter the <em>Blocks <\/em>view and create the logic behind your user interface elements and the non-visible components. Here, you define what happens once you interact with the screen and the different parts on it, like sliders, buttons, or labels. Also, think about what actions should take place when Bluetooth connects or disconnects, receives a message, or sends a message to the Pmod BLE.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.digilent.com\/blog\/wp-content\/uploads\/2022\/08\/31.png\" alt=\"\" width=\"1500\" height=\"791\" class=\"aligncenter size-full wp-image-29330\" data-wp-pid=\"29330\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/31.png 1500w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/31-600x316.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/08\/31-1024x540.png 1024w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/p>\n<p>Give a thought to the format you want to send the data in. Also review the data formats of the Pmods and how you intend to interpret them.<\/p>\n<p>If asked for the MAC address for the Pmod BLE, the service UUID, and the Characteristic UUID, refer to your notes from the second part of this blog series. There, you jotted them down.<\/p>\n<p>If you believe you are all set, build the application and install it on your phone. Remember that it must allow installations from unknown sources.<\/p>\n<h2>Designing the LED Driver Circuit<\/h2>\n<p>Now it is time to design and assemble the LED driver. Here, to achieve linear brightness changes, you will need to control the current through the LED; just controlling the voltage is not sufficient. The ADP3450 does not feature a current supply, so you will have to design a voltage controlled current sink for each of the LED\u2019s colors.<\/p>\n<p>The various voltages are created through PWM signals on the digital lines of the ADP3450, which you should connect to a low-pass filter. Have a look at the schematic below . Calculate the power dissipation and choose an adequate resistor. Finally, attach everything to the battery as shown.<\/p>\n<h2>Building the Charger Circuit<\/h2>\n<p>As a last step, create the charger circuit for the lithium-polymer battery cell. Use an <a href=\"https:\/\/www.analog.com\/media\/en\/technical-documentation\/data-sheets\/lt3092.pdf\">LT 3092<\/a> programmable current source from Analog Devices for that and connect it with a USB-A plug to one of the USB ports at the back of the ADP3450. These provide enough power for charging the battery. Refer to the schematic below for details.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.digilent.com\/blog\/wp-content\/uploads\/2022\/08\/Battery-Charger.jpg\" alt=\"\" width=\"426\" height=\"230\" class=\"aligncenter size-full wp-image-29332\" data-wp-pid=\"29332\" \/><\/p>\n<p class=\"iE-Fliesstext\">With that done, you can move on to create the final application running on the Analog Discovery Pro ADP3450. That, and a description on how to test it, will be part of the fourth (and last) installment of this blog series.<o:p><\/o:p><\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-29329 jlk' data-task='like' data-post_id='29329' data-nonce='919968f71f' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-29329 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-29329 jlk' data-task='unlike' data-post_id='29329' data-nonce='919968f71f' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-29329 unlc'>0<\/span><\/a><\/div><\/div> <div class='status-29329 status align-left'>Be the 1st to vote.<\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>In this third issue of our four-part blog post series covering the creation of a smart LED-lamp, we are designing the Android app controlling brightness and state of the LED. &hellip; <\/p>\n","protected":false},"author":61,"featured_media":29229,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4327,4323,4312,1563],"tags":[4352,4367],"ppma_author":[4506],"class_list":["post-29329","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-software","category-usb-scopes-analyzers-generators","category-guide","tag-adp3450","tag-multisim"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2022\/06\/smartlamp1.jpg","authors":[{"term_id":4506,"user_id":61,"is_guest":0,"slug":"richardoed","display_name":"Richard Oed","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/9478380d8e084e6d82ce401aa32d9d85?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Oed","last_name_2":"","first_name":"Richard","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/29329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/61"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=29329"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/29329\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/29229"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=29329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=29329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=29329"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=29329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}