Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MTroj
Novice
1,197 Views

Web server update value of analog pin on graph

Hello, I'm trying to build a web server that will updating a value of analog pin on a canvas chart. My code:

client.println("HTTP/1.1 200 OK");

client.println("Content-Type: text/html");

client.println("Connection: close");

client.println();

client.println("<!DOCTYPE HTML>");

client.println("");

client.println(" https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\"> https://canvasjs.com/assets/script/canvasjs.min.js\">");

client.println("");

client.println("");

client.println("");

client.println("window.onload = function () {var dps = []; var chart = new CanvasJS.Chart(\"chartContainer\", { axisY: { includeZero: false }, data: [{ type: \"line\", dataPoints: dps }]});var xVal = 0;var yVal = 0; var updateInterval = 52;var dataLength = 50; var updateChart = function (count) { count = count || 1; for (var j = 0; j < count; j++) { yVal = "+String(analogRead(A0))+"; dps.push({ x: xVal, y: yVal }); xVal++; } if (dps.length > dataLength) { dps.shift(); } chart.render();};updateChart(dataLength);setInterval(function(){updateChart()}, updateInterval);}");

client.println("");

client.println("");

client.println("");

I know why it doesn't work (it is displaying the same value all the time) but how get it to work?

0 Kudos
2 Replies
idata
Community Manager
96 Views

Hello Michal,

 

 

Thank you for your interest in the Intel Edison platform.

 

 

Can you please describe more about your issue in order to better help you?

 

What is the issue with the board?

 

Are you having trouble reading the values from analog pin 0?

 

What analog values are you sending to pin analog 0?

 

 

Regards,

 

Octavian
idata
Community Manager
96 Views

Hello Michal,

 

 

Do you still require assistance with this issue?

 

 

Regards,

 

Octavian
Reply