Anonymous

Project:Nanode/Applications: Difference between revisions

From London Hackspace Wiki
m
no edit summary
mNo edit summary
Line 260: Line 260:
Now re-compile and upload and refresh your browser window - you should see the text changes you made in the code reflected in the served page.
Now re-compile and upload and refresh your browser window - you should see the text changes you made in the code reflected in the served page.


'''Analogue Inputs'''
It's quite straight forward to add the analogue readings from sensors to the web page.
We first have to read the ADC input, convert the resulting number to ASCII, and put that number into a string. Then we copy those strings into the buffer which makes up the tcp sending buffer.
Here's the code to read analogue 0
Remember to include the string library and the standard libray
  #include <stdlib.h>
  #include <string.h>
  // Read the 6 analogue inputs in turn, convert the ADC result to ASCII and put into numstr
  // Then copy from RAM, the numstr and put into the tcp send buffer to send to the web page
 
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<br> A0: "));
  itoa(analogRead(0),numstr,10); // convert integer to string
  plen=es.ES_fill_tcp_data(buf,plen,numstr);




552

edits