{"id":3012,"date":"2016-09-26T12:03:56","date_gmt":"2016-09-26T10:03:56","guid":{"rendered":"http:\/\/liceocuneo.it\/oddenino\/?p=3012"},"modified":"2016-09-26T12:03:56","modified_gmt":"2016-09-26T10:03:56","slug":"gestione-di-piu-eventi-in-parallelo","status":"publish","type":"post","link":"https:\/\/liceocuneo.it\/oddenino\/gestione-di-piu-eventi-in-parallelo\/","title":{"rendered":"Gestione di pi\u00f9 eventi in parallelo"},"content":{"rendered":"<p>Modificare il programma realizzato in classe in modo che gestisca anche i 2 sensori restanti: il TouchSensor e l&#8217;UltrasonicSensor e visualizzi i valori sulle righe 2 e 3.<\/p>\n<pre>import lejos.nxt.Button;\r\nimport lejos.nxt.LCD;\r\nimport lejos.nxt.LightSensor;\r\nimport lejos.nxt.SensorPort;\r\nimport lejos.nxt.SensorPortListener;\r\nimport lejos.nxt.SoundSensor;\r\n\r\npublic class SensoriInsieme {\r\n\r\n\tLightSensor ls;\r\n\tSoundSensor ss;\r\n\r\n\tprivate class AscoltaLuce implements SensorPortListener {\r\n\r\n\t\t@Override\r\n\t\tpublic void stateChanged(SensorPort aSource, int aOldValue, int aNewValue) {\r\n\t\t\tint value = ls.readValue();\r\n\t\t\tLCD.drawString(\"LS=\" + value + \"   \", 0, 0);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tprivate class AscoltaSuono implements SensorPortListener {\r\n\r\n\t\t@Override\r\n\t\tpublic void stateChanged(SensorPort aSource, int aOldValue, int aNewValue) {\r\n\t\t\tint value = ss.readValue();\r\n\t\t\tLCD.drawString(\"SS=\" + value + \"   \", 0, 1);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tpublic SensoriInsieme() {\r\n\t\tls = new LightSensor(SensorPort.S1);\r\n\t\tss = new SoundSensor(SensorPort.S2);\r\n\t\tSensorPort.S1.addSensorPortListener(new AscoltaLuce());\r\n\t\tSensorPort.S2.addSensorPortListener(new AscoltaSuono());\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tnew SensoriInsieme();\r\n\t\tButton.ESCAPE.waitForPressAndRelease();\r\n\t}\r\n\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Modificare il programma realizzato in classe in modo che gestisca anche i 2 sensori restanti: il TouchSensor e l&#8217;UltrasonicSensor e visualizzi i valori sulle righe 2 e 3. import lejos.nxt.Button; import lejos.nxt.LCD; import lejos.nxt.LightSensor; import lejos.nxt.SensorPort; import lejos.nxt.SensorPortListener; import lejos.nxt.SoundSensor; public class SensoriInsieme { LightSensor ls; SoundSensor ss; private class AscoltaLuce implements SensorPortListener { @Override &hellip; <a href=\"https:\/\/liceocuneo.it\/oddenino\/gestione-di-piu-eventi-in-parallelo\/\" class=\"more-link\">Continua a leggere <span class=\"screen-reader-text\">Gestione di pi\u00f9 eventi in parallelo<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-3012","post","type-post","status-publish","format-standard","hentry","category-informatica"],"_links":{"self":[{"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/posts\/3012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/comments?post=3012"}],"version-history":[{"count":0,"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/posts\/3012\/revisions"}],"wp:attachment":[{"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/media?parent=3012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/categories?post=3012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/liceocuneo.it\/oddenino\/wp-json\/wp\/v2\/tags?post=3012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}