A tutoriel to read analog input with Esus board.
How to read an analog input ?
To read an analog input, here is a function to be used:
unsigned int MCP3008_read(int channel);
This function returns a value between 0 and 1023. In parameter, the channel is a value between A0 and A5.
Read analog input A0
Here is an example of reading the A0 analog input.
#include <esusBoard.h>
unsigned int data;
void setup()
{
// init esus board
initEsusBoard();
Serial.begin(9600);
}
void loop()
{
data = MCP3008_read(A0);
Serial.println(data);
delay(1000);
}

Read all inputs
Program for read all the analog input:
#include <esusBoard.h>
unsigned int data,c;
void setup()
{
// init esus board
initEsusBoard();
Serial.begin(9600);
}
void loop()
{
for(c=0;c != 6; c++)
{
data = MCP3008_read(c);
Serial.println(data);
delay(1000);
}
}
