I am using a I2C Sensor on an Arduino UNO with wiznet ethenet shield. How can i implement pin reading and pin writing in to this excisting code?
#include <Wire.h>
#include <SSC.h>
#include <SPI.h>
#include <Ethernet.h>
boolean reading = false;
// create an SSC sensor with I2C address 0x78 and power pin 8.
SSC ssc(0x28, 8);
////////////////////////////////////////////////////////////////////////
//CONFIGURE
////////////////////////////////////////////////////////////////////////
byte mac[] = {
0x12, 0x34, 0x45, 0x78, 0x9A, 0xB0 };
IPAddress ip(192,168,1,150);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 85 is default for HTTP):
EthernetServer server(85);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
Wire.begin();
// set min / max reading and pressure, see datasheet for the values for your sensor
ssc.setMinRaw(1638);
ssc.setMaxRaw(14742);
ssc.setMinPressure(0);
ssc.setMaxPressure(100);
// start the sensor
Serial.print("start()\t\t");
Serial.println(ssc.start());
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
Serial.println(ssc.update());
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 1"); // refresh the page automatically every 5 sec
client.println();
client.println("");
client.println("");
// output the value of HSC
{
client.print("value at HSC ");
client.print(" is ");
client.print(ssc.pressure());
client.println("
");
}
client.println("");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}