Skip to content

Instantly share code, notes, and snippets.

@Bouhnosaure
Created May 22, 2015 22:25
Show Gist options
  • Save Bouhnosaure/60a7ae8b8fb912e3b7f1 to your computer and use it in GitHub Desktop.
Save Bouhnosaure/60a7ae8b8fb912e3b7f1 to your computer and use it in GitHub Desktop.
arduino.c
int photocellPin = A1;
int photocellReading;
const int sensorPin = 0;
const int hydroAnalog = A2;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
int sensorVal = analogRead(sensorPin);
photocellReading = analogRead(photocellPin);
float voltage = (sensorVal/1024.0) * 5.0;
float temperature = (voltage - .5) * 100;
int hydroReading = analogRead(hydroAnalog);
float pourcentHydro = (hydroReading * 100)/ 800;
Serial.print(photocellReading);
Serial.print("|");
Serial.print(temperature);
Serial.print("|");
Serial.print(pourcentHydro);
Serial.print("\n\r");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment