-
-
Save turingmachine/21f4127015cc8ec0484040383080dc85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int poti1 = A0; // Analog input pin that the Ph probe is connected. | |
//const int poti2 = A1; // Analog input pin that the Ph probe is connected. | |
int sensorValue = 0; // 10bit value read from the PH probe. | |
byte address = 4; // 00000100, first possible address. | |
byte PhLo = 0; // Lo-byte of 10 bit data. | |
byte PhHi = 0; // Hi-byte of 10 bit data. | |
void setup() { | |
Serial.begin(9600); | |
} | |
void loop() { | |
sendData(1, analogRead(poti1)); | |
//sendData(2, analogRead(poti2)); | |
//Serial.println(analogRead(poti1)); | |
delay(25); // change value for slower data transfer. | |
} | |
void sendData(int address, int value) { | |
PhHi = address | value>>8; // merge adddress and upper byte. | |
PhLo = value; // lower byte. | |
Serial.write(0); // header byte. | |
Serial.write(PhHi); // first byte. | |
Serial.write(PhLo); // second byte. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment