problem with second potentiometer
Tagged: potentiometer
- This topic has 0 replies, 1 voice, and was last updated 7 years, 3 months ago by Anonymous.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
December 9, 2015 at 3:47 PM #1039AnonymousInactive
Hello! right now i would like use two Potentiometer to control different things. The first I just use the code from example”Analog Inout”. And i when want read the number of another potentiometer in same way. That don’t worked anymore. Besides after i write new code, console.log() or basically oder like $(‘#poti2’).text(“poti2 = ” + valueIn.toFixed(0)); don’t worked any more either. My board is Arduino Uno, laptop running on mac system. I hope someone can tell me, where is the mistake from my code. thanks!
followed is my code
<!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <style type="text/css"> body { margin: 15px; width: 300px; font-family: sans-serif; font-size: 18px; color: #666; } h2 { font-weight: normal; font-size: 28px; padding-bottom: 20px; color: #00AEFF; } .container { background-color: #f7f7f7; padding: 0 10px 20px 10px; border: 1px dotted #CCC; width: 270px; margin-top: 20px; } .progressbar { background-color: #f7f7f7; width: 270px; margin-bottom: 0; display: none; } .pic{ width: 400px; } #pic2{ position: absolute; top: 94px; } </style> <title>Analog Input</title> <!-- The following (socket.io.js) is only required when using the node_server --> <script src="../../socket.io/socket.io.js"></script> <script src="../../dist/Breakout.min.js"></script> <script src="../libs/jquery.min.js"></script> <!-- Only needed for the visualization (progress bar) --> <script src="../libs/jquery-ui/jquery-ui.custom.min.js"></script> <link href="../libs/jquery-ui/jquery-ui.custom.css" rel="stylesheet" type="text/css"/> <script type="text/javascript"> $(document).ready(function() { // Declare these variables so you don't have // to type the full namespace var IOBoard = BO.IOBoard; var IOBoardEvent = BO.IOBoardEvent; var Pin = BO.Pin; var PinEvent = BO.PinEvent; // If you are not serving this file from the same computer // that the Arduino board is connected to, replace // window.location.hostname with the IP address or hostname // of the computer that the Arduino board is connected to. var host = window.location.hostname; // if the file is opened locally, set the host to "localhost" if (window.location.protocol.indexOf("file:") === 0) { host = "localhost"; } var arduino = new IOBoard(host, 8887); var $analogVal = $('#value'); var $analogA2 = $('#poti2') var $progressBar = $("#progressbar"); var $pic2 = $('#pic2'); // Listen for the IOBoard READY event which indicates the IOBoard // is ready to send and receive data arduino.addEventListener(IOBoardEvent.READY, onReady); function onReady(event) { // Remove the event listener because it is no longer needed arduino.removeEventListener(IOBoardEvent.READY, onReady); // Enable the analog pin so we can read its value arduino.enableAnalogPin(0); var sensor = arduino.getAnalogPin(0); sensor.addEventListener(PinEvent.CHANGE, onChange); arduino.enableAnalogPin(1); var okular = arudino.getAnalogPin(1); okular.addEventListener(PinEvent.CHANGE, modelChange); // console.log("test") } function onChange(evt) { // The potentiometer gives back a value between 0 and 1.0 var valueIn = evt.target.value; var value = valueIn * 100; $analogVal.text("Value = " + value.toFixed(0)); $progressBar.progressbar({ value: value }); if(valueIn>0.2){ $pic2.css('display', 'block'); } else{ $pic2.css('display', 'none'); } return value; console.log(valueIn); } function modelChange(evt){ var value2 = evt.target.value; var value = value2 * 100 $('#poti2').text("poti2 = " + valueIn.toFixed(0)); } }); </script> </head> <body> <h2>Quastenflosser</h2> <div class="container"> <p id="value"></p> <p id="poti2"></p> <p id="progressbar" class="progressbar"></p> </div> <div class ="pic"> <img id="pic1" class = "pic" src="images/1.0.jpg"> <img id="pic2" class = "pic" src="images/2.0.jpg"> </div> </body> </html>
-
AuthorPosts
Viewing 1 post (of 1 total)
- The forum ‘Forum’ is closed to new topics and replies.