{"id":952,"date":"2018-04-03T00:26:23","date_gmt":"2018-04-03T00:26:23","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=952"},"modified":"2018-04-03T00:26:23","modified_gmt":"2018-04-03T00:26:23","slug":"processing-and-arduino-ep2-sliders","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=952","title":{"rendered":"Processing and Arduino EP#2 sliders"},"content":{"rendered":"<h1>In this tutorial we will take a look at using sliders from processing to control pwm pins of the Arduino..<\/h1>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" title=\"Processing and Arduino EP#2 sliders\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/6wCFE6ZnVWI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<h2>Processing Code:<\/h2>\n<p>import controlP5.*; \/\/library<br \/>\nimport processing.serial.*; \/\/library<br \/>\nSerial port; \/\/do not change<br \/>\nControlP5 cp5; \/\/create ControlP5 object<br \/>\n\/\/int led;<\/p>\n<p>void setup() {<\/p>\n<p>size(300, 300); \/\/window size, (width, height)<br \/>\nport = new Serial(this, &#8220;COM3&#8221;, 9600); \/\/connected arduino port<br \/>\ncp5 = new ControlP5(this); \/\/do not change<\/p>\n<p>cp5.addSlider(&#8220;led&#8221;)<br \/>\n.setPosition(125, 20) \/\/x and y upper left corner<br \/>\n.setSize(50, 250) \/\/(width, height)<br \/>\n.setRange(0, 255) \/\/slider range low,high<br \/>\n.setValue(125) \/\/start val<br \/>\n.setColorBackground(color(0, 0, 255)) \/\/top of slider color r,g,b<br \/>\n.setColorForeground(color(0, 255, 0)) \/\/botom of slider color r,g,b<br \/>\n.setColorValue(color(255, 255, 255)) \/\/vall color r,g,b<br \/>\n.setColorActive(color(255, 0, 0)) \/\/mouse over color<br \/>\n;<br \/>\n}<\/p>\n<p>void draw() {<\/p>\n<p>background(0, 0, 0); \/\/ background color of window (r, g, b)<br \/>\n}<\/p>\n<p>void led(int led)<br \/>\n{<br \/>\nport.write(led);<br \/>\n}<\/p>\n<h2>Arduino Code:<\/h2>\n<p>#define led 11<br \/>\nint val = 125;<br \/>\nvoid setup() {<\/p>\n<p>pinMode(led, OUTPUT); \/\/set pin as output , red led<br \/>\nanalogWrite(led,val);<\/p>\n<p>Serial.begin(9600); \/\/start serial<br \/>\n}<\/p>\n<p>void loop(){<\/p>\n<p>if(Serial.available()){ \/\/if data available<\/p>\n<p>int val = Serial.read();<\/p>\n<p>analogWrite(led,val);<\/p>\n<p>}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will take a look at using sliders from processing to control pwm pins of the Arduino.. &nbsp; &nbsp; Processing Code: import controlP5.*; \/\/library import processing.serial.*; \/\/library Serial port; \/\/do not change ControlP5 cp5; \/\/create ControlP5 object &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=952\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":947,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-952","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=952"}],"version-history":[{"count":0,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/952\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/947"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}