{"id":209,"date":"2017-04-04T11:45:28","date_gmt":"2017-04-04T11:45:28","guid":{"rendered":"http:\/\/ulm.taddug.com\/?p=209"},"modified":"2017-08-07T23:11:33","modified_gmt":"2017-08-07T23:11:33","slug":"bowl-alpha","status":"publish","type":"post","link":"https:\/\/ulm.taddug.com\/index.php\/2017\/04\/04\/bowl-alpha\/","title":{"rendered":"bowl alpha"},"content":{"rendered":"<p>Latest sketch and notes:<\/p>\n<p>all hardware has been secured on the breadboard with my testbed arduino uno. so far concerns are back chatter &#8212; the power lines are not clean and I have isolated the main components of speaker and bluetooth transmitter\/receiver on the board with some limiting resistors. my display values are unstable at startup after physical manipulation but can be returned to null after re-adjusting the connections. In particular, the pairing of the BT is reflected by an immediate 5 to 6 impedance drop on the soft pot lines, so for now, all testing begins only after pairing is complete.<\/p>\n<p>the uno revision 3 should eliminate these issues as all power and ground lines are isolated on the board.<\/p>\n<p>mac address for BT has been hard coded for tablet app and I have completed the bluetooth library integration in my app.<\/p>\n<p>audio: currently utilizing TONE.h library for arduino to allow for software modulation of two tones simultaneously but this is not the final plan<\/p>\n<p>all physical components are working without interference [other than power mentioned above]. testing has shown consistent performance over several hours.<\/p>\n<p>Next Phase: will need to integrate BTLE beacon hardware and software<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/when sending from serial be sure both NL and CR are on and baud rate matches<br \/>\n\/\/ ended up needing to use RX pin 0 and TX pin 1<br \/>\n\/\/ SR will be .25 seconds<\/p>\n<p>\/\/ HARDWARE<br \/>\n#include &lt;Timer.h&gt;<br \/>\n#include &lt;Event.h&gt;<br \/>\n#include &#8220;Arduino.h&#8221;<br \/>\n#include &lt;SoftwareSerial.h&gt;<br \/>\n#include &#8220;DFRobotDFPlayerMini.h&#8221;<\/p>\n<p>SoftwareSerial mySoftwareSerial(10, 11); \/\/ RX, TX<br \/>\nDFRobotDFPlayerMini myDFPlayer;<\/p>\n<p>\/\/ VARIABLES<br \/>\nconst int sr = 250; \/\/worked for a very long time \/\/ sample rate in ms??<br \/>\nconst int le = 14; \/\/20; \/\/2; \/\/40; \/\/ Low end of travel<br \/>\nconst int he = 80; \/\/50; was great \/\/100; \/\/ High end of travel<br \/>\nconst int baseSV = 20; \/\/should be 10 but 20 when things are putting it above 0 on no touch<br \/>\nint dir = 1; \/\/ 1 is clockwise -1 is counterclockwise<\/p>\n<p>const int SENSOR_PIN = 0; \/\/0 was working great \/\/ Pin for ribbon<br \/>\nconst int SENSOR_PIN2 = 1; \/\/1 was working with 0 great \/\/pin for ribbon2<br \/>\nconst int LED_PIN = 13; \/\/12; \/\/ LED pin location<\/p>\n<p>bool flowing = false;<br \/>\nbool prevFlow = false;<br \/>\nint prevRead = 0;<\/p>\n<p>bool isPlay=false;<br \/>\nint myVol=24;<br \/>\nint curVol=0;<\/p>\n<p>Timer t;<\/p>\n<p>\/\/ SETUP<br \/>\nvoid setup()<br \/>\n{<br \/>\nmySoftwareSerial.begin(9600);<br \/>\nSerial.begin(9600);<br \/>\n\/\/Serial.println(&#8220;setup&#8221;);<br \/>\npinMode( LED_PIN, OUTPUT );<br \/>\nint senseEvent = t.every(sr, sensorCheck);<\/p>\n<p>myDFPlayer.begin(mySoftwareSerial);<br \/>\nmyDFPlayer.volume(myVol); \/\/Set volume value. From 0 to 30<br \/>\nmyDFPlayer.enableLoopAll();<br \/>\nmyDFPlayer.play(4);<br \/>\nmyDFPlayer.pause();<br \/>\n}<\/p>\n<p>\/\/ LOOP<br \/>\nvoid loop() {<br \/>\nt.update();<br \/>\n\/*<br \/>\nif(isPlay){<br \/>\nmyDFPlayer.volume(myVol++);<br \/>\n}<br \/>\nelse {<br \/>\nmyDFPlayer.volume(myVol&#8211;);<br \/>\n}<\/p>\n<p>if (isPlay){<br \/>\n\/\/if(myDFPlayer.readVolume()&lt;15){<br \/>\nmyDFPlayer.volumeUp();<br \/>\n\/\/}<br \/>\n}<br \/>\nelse {<br \/>\nif(myDFPlayer.readVolume()&gt;0){<br \/>\nmyDFPlayer.volumeDown();<br \/>\n}<br \/>\n}<br \/>\n*\/<\/p>\n<p>if(Serial.available()){ \/\/LAST change was getting rid of just serial avail, but everything inside was commented<br \/>\n\/\/this works to get data back from Android<br \/>\n\/\/Serial.println(Serial.read());<br \/>\n\/\/char valA=Serial.read();<br \/>\n\/\/if (valA==&#8217;a&#8217;)<br \/>\n\/\/Serial.println(&#8220;IT WAS AN A&#8221;);<br \/>\n}<\/p>\n<p>}<\/p>\n<p>\/\/ SENSORCHECK<br \/>\nvoid sensorCheck () {<br \/>\nint sensorVal = analogRead( SENSOR_PIN );<br \/>\nint sensorVal2 = analogRead( SENSOR_PIN2);<br \/>\n\/\/TENU TEST AREA<\/p>\n<p>Serial.print(&#8220;VAL ONE &#8220;);<br \/>\nSerial.println(sensorVal);<\/p>\n<p>Serial.print(&#8220;VAL tWO &#8220;);<br \/>\nSerial.println(sensorVal2);<\/p>\n<p>int sensDelta=0;<br \/>\nif((sensorVal&gt;baseSV)&amp;&amp;(sensorVal2&lt;baseSV)) \/\/only hitting s1<br \/>\n{<br \/>\nsensDelta = sensorVal &#8211; prevRead;<br \/>\nprevRead = sensorVal;<br \/>\n}<br \/>\nif ((sensorVal2&gt;baseSV)&amp;&amp;(sensorVal&lt;baseSV)) \/\/only hitting s2<br \/>\n{<br \/>\nsensDelta = sensorVal2 &#8211; prevRead;<br \/>\nprevRead = sensorVal2;<br \/>\n}<\/p>\n<p>if ((sensorVal&gt;baseSV) &amp;&amp; (sensorVal2&gt;baseSV)) { \/\/touching both<br \/>\nprevRead=0;<br \/>\n}<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nsensDelta=abs(sensDelta);<\/p>\n<p>if ( ( sensDelta &gt; le ) &amp;&amp; ( sensDelta &lt; he ) ) {<br \/>\nflowing = true;<\/p>\n<p>if ( (prevFlow==true) )<br \/>\n{<br \/>\nSerial.println(&#8220;T&#8221;);<br \/>\ndigitalWrite(LED_PIN, HIGH);<br \/>\ntonePlay();<br \/>\n} else {<br \/>\nSerial.println(&#8220;F&#8221;);<br \/>\ndigitalWrite(LED_PIN, LOW);<br \/>\nisPlay=false;<br \/>\ncallPause();<br \/>\n} \/\/end Bblock<\/p>\n<p>prevFlow = flowing;<br \/>\nflowing = false;<br \/>\n}<br \/>\nelse { \/\/sensDelta was not in range<br \/>\ndigitalWrite( LED_PIN, LOW );<br \/>\nif (prevFlow == true) { \/\/has moved from flow to no flow<br \/>\nprevFlow = false;<br \/>\nSerial.println(&#8220;F&#8221;);<br \/>\nisPlay=false;<br \/>\ncallPause();<br \/>\n}\/\/end if prevFlow<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ TONEPLAY<br \/>\nvoid tonePlay() {<\/p>\n<p>if(!isPlay) {<br \/>\nisPlay=true;<br \/>\nmyDFPlayer.volume(myVol);<br \/>\ncurVol=myVol;<br \/>\nmyDFPlayer.start();<br \/>\n}<\/p>\n<p>}<br \/>\n\/\/ CALLPAUSE<br \/>\nvoid callPause() {<br \/>\nfor(int i=curVol; i&#8211;; i&gt;-1)<br \/>\n{<br \/>\nmyDFPlayer.volume(&#8211;curVol);<br \/>\n\/\/myDFPlayer.volumeDown();<br \/>\n\/\/curVol&#8211;;<br \/>\ndelay(10);<br \/>\n}<\/p>\n<p>myDFPlayer.pause();<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Latest sketch and notes: all hardware has been secured on the breadboard with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,5,1],"tags":[],"class_list":["post-209","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pieces","category-research","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/posts\/209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/comments?post=209"}],"version-history":[{"count":1,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/posts\/209\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/posts\/209\/revisions\/210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/media\/262"}],"wp:attachment":[{"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/media?parent=209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/categories?post=209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ulm.taddug.com\/index.php\/wp-json\/wp\/v2\/tags?post=209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}