problem with second potentiometer

About Forums Forum problem with second potentiometer


Viewing 1 post (of 1 total)
  • Author
  • #1039

    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>
    <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;
        width: 400px;
        position: absolute;
        top: 94px;
    <title>Analog Input</title>
    <!-- The following ( is only required when using the node_server -->
    <script src="../../"></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
            var sensor = arduino.getAnalogPin(0);
            sensor.addEventListener(PinEvent.CHANGE, onChange);
            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 =;
            var value = valueIn * 100;
            $analogVal.text("Value = " + value.toFixed(0));
            $progressBar.progressbar({ value: value });
                $pic2.css('display', 'block');
            } else{
                $pic2.css('display', 'none');
            return value;
        function modelChange(evt){
            var value2 =;
            var value = value2 * 100
            $('#poti2').text("poti2 = " + valueIn.toFixed(0));
            <div class="container">
                <p id="value"></p>
                <p id="poti2"></p>
                <p id="progressbar" class="progressbar"></p>
            <div class ="pic">  
                    <img id="pic1" class = "pic" src="images/1.0.jpg">
                    <img id="pic2" class = "pic" src="images/2.0.jpg">
Viewing 1 post (of 1 total)
  • The forum ‘Forum’ is closed to new topics and replies.