{"id":692,"date":"2016-09-13T21:15:53","date_gmt":"2016-09-14T04:15:53","guid":{"rendered":"http:\/\/blogs.ischool.berkeley.edu\/i262\/?p=692"},"modified":"2016-09-13T21:15:53","modified_gmt":"2016-09-14T04:15:53","slug":"creating-my-own-mini-glacier","status":"publish","type":"post","link":"https:\/\/blogs.ischool.berkeley.edu\/i262\/2016\/09\/13\/creating-my-own-mini-glacier\/","title":{"rendered":"Creating My Own Mini Glacier"},"content":{"rendered":"<p>For this project, I attempted to recreate the glaciers I saw on a recent trip to Iceland. The jagged edges of the ice coupled with the pure blue color was an image that I&#8217;ll never forget and wanted to replicate. I used an Arduino board and 3 LEDs &#8211; Red, Green, and Blue &#8211; and I used a plastic shower cap to diffuse the light.\u00a0Using specific keystrokes I was able to control the intensity of each of the LED&#8217;s brightness. For example, by pressing\u00a0capital &#8220;R&#8221;, &#8220;G&#8221;, or &#8220;B&#8221; would result in the corresponding LED to increase it&#8217;s brightness by 50. If the lowercase letter was pressed, the intensity would increase by 15.<\/p>\n<p>Components:<\/p>\n<ol>\n<li>Adruino board<\/li>\n<li>Breadboard<\/li>\n<li>3 LEDs (red, green, blue)<\/li>\n<li>3 ohm resistors<\/li>\n<li>4 wires<\/li>\n<li>1 plastic shower cap<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>Code:<\/p>\n<p>char serInString[100]; \/\/ array that will hold the different bytes of the string. 100=100characters;<br \/>\n\/\/ -&gt; you must state how long the array will be else it won&#8217;t work properly<br \/>\nchar colorCode;<br \/>\nint colorVal;<br \/>\nint redVal;<br \/>\nint greenVal;<br \/>\nint blueVal;<br \/>\nint redPin = 9; \/\/ Red LED, connected to digital pin 9<br \/>\nint greenPin = 10; \/\/ Green LED, connected to digital pin 10<br \/>\nint bluePin = 11; \/\/ Blue LED, connected to digital pin 11<br \/>\nvoid setup() {<br \/>\npinMode(redPin, OUTPUT); \/\/ sets the pins as output<br \/>\npinMode(greenPin, OUTPUT);<br \/>\npinMode(bluePin, OUTPUT);<br \/>\nSerial.begin(9600);<br \/>\nanalogWrite(redPin, 127); \/\/ set them all mid-brightness<br \/>\nanalogWrite(greenPin, 127); \/\/ set them all mid-brightness<br \/>\nanalogWrite(bluePin, 127); \/\/ set them all mid-brightness<br \/>\nSerial.println(&#8220;enter color command using r&#8217;s, b&#8217;s, g&#8217;s, R&#8217;s, B&#8217;s, and G&#8217;s (e.g. &#8216;rrrrrrggggg&#8217; &#8216;RRBBGG&#8217; RRRRR&#8217;) :&#8221;);<br \/>\n}<br \/>\nvoid loop () {<br \/>\n\/\/ clear the string<br \/>\nmemset(serInString, 0, 100);<br \/>\n\/\/read the serial port and create a string out of what you read<br \/>\nreadSerialString(serInString);<br \/>\n\/\/ initialize all back to zero for each loop<br \/>\nredVal = 0;<br \/>\ngreenVal = 0;<br \/>\nblueVal = 0;<br \/>\ncolorCode = serInString[0];<br \/>\nif( colorCode == &#8216;r&#8217; || colorCode == &#8216;g&#8217; || colorCode == &#8216;b&#8217; || colorCode == &#8216;R&#8217; || colorCode == &#8216;G&#8217; || colorCode == &#8216;B&#8217;) {<br \/>\n\/\/ increment each color based on number of each letter<br \/>\nfor (int i = 0; i &lt; strlen(serInString); i++) {<br \/>\nswitch(serInString[i]) {<br \/>\ncase &#8216;r&#8217;:<br \/>\nredVal += 15;<br \/>\nbreak;<br \/>\ncase &#8216;g&#8217;:<br \/>\ngreenVal += 15;<br \/>\nbreak;<br \/>\ncase &#8216;b&#8217;:<br \/>\nblueVal += 15;<br \/>\nbreak;<br \/>\ncase &#8216;R&#8217;:<br \/>\nredVal += 50;<br \/>\nbreak;<br \/>\ncase &#8216;G&#8217;:<br \/>\ngreenVal += 50;<br \/>\nbreak;<br \/>\ncase &#8216;B&#8217;:<br \/>\nblueVal += 50;<br \/>\n}<br \/>\n}<br \/>\nSerial.print(&#8220;Setting color &#8220;);<br \/>\nSerial.println();<br \/>\nSerial.print(&#8220;red to &#8220;);<br \/>\nSerial.print(redVal);<br \/>\nSerial.println();<br \/>\nSerial.print(&#8220;green to &#8220;);<br \/>\nSerial.print(greenVal);<br \/>\nSerial.println();<br \/>\nSerial.print(&#8220;blue to &#8220;);<br \/>\nSerial.print(blueVal);<br \/>\nSerial.println();<br \/>\nserInString[0] = 0; \/\/ indicates we&#8217;ve used this string<br \/>\nanalogWrite(redPin, redVal);<br \/>\nanalogWrite(greenPin, greenVal);<br \/>\nanalogWrite(bluePin, blueVal);<br \/>\n}<br \/>\ndelay(100); \/\/ wait a bit, for serial data<br \/>\n}<br \/>\n\/\/read a string from the serial and store it in an array<br \/>\n\/\/you must supply the array variable<br \/>\nvoid readSerialString (char *strArray) {<br \/>\nint i = 0;<br \/>\nif(!Serial.available()) {<br \/>\nreturn;<br \/>\n}<br \/>\nwhile (Serial.available()) {<br \/>\nstrArray[i] = Serial.read();<br \/>\ni++;<br \/>\n}<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-705\" src=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/DSC_0411-300x201.jpg\" alt=\"DSC_0411\" width=\"300\" height=\"201\" srcset=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/DSC_0411-300x201.jpg 300w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/DSC_0411-768x514.jpg 768w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/DSC_0411-1024x685.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Below an Icelandic glacier; what I wanted to mimic.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-700\" src=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7384-e1473826040254-225x300.jpg\" alt=\"IMG_7384\" width=\"225\" height=\"300\" srcset=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7384-e1473826040254-225x300.jpg 225w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7384-e1473826040254-768x1024.jpg 768w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-701\" src=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7385-300x225.jpg\" alt=\"IMG_7385\" width=\"300\" height=\"225\" srcset=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7385-300x225.jpg 300w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7385-768x576.jpg 768w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7385-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-702\" src=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7386-300x225.jpg\" alt=\"IMG_7386\" width=\"300\" height=\"225\" srcset=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7386-300x225.jpg 300w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7386-768x576.jpg 768w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7386-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-703\" src=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7387-300x225.jpg\" alt=\"IMG_7387\" width=\"300\" height=\"225\" srcset=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7387-300x225.jpg 300w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7387-768x576.jpg 768w, https:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7387-1024x768.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><a href=\"http:\/\/blogs.ischool.berkeley.edu\/i262\/files\/2016\/09\/IMG_7389.TRIM_.mov\" target=\"_blank\">Lights changing video<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For this project, I attempted to recreate the glaciers I saw on a recent trip to Iceland. The jagged edges of the ice coupled with the pure blue color was an image that I&#8217;ll never forget and wanted to replicate. &hellip; <a href=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/2016\/09\/13\/creating-my-own-mini-glacier\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3258,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63434],"tags":[],"class_list":["post-692","post","type-post","status-publish","format-standard","hentry","category-lab02"],"_links":{"self":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/users\/3258"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":0,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}