tuinkabouter
Well-known member
zat er een aansluit handleiding of iets bij?
// Fisk Tank Controller by G.M.G.T. Seegers 2015 Version 3
// V3 contains capacitive sensor control for the LCD
// involved Libraries
#include <OneWire.h>
#include <LiquidCrystal_I2C.h>
#include <CapacitiveSensor.h>
#include <Wire.h>
#include "RTClib.h"
#include <Time.h>
#include <TimeAlarms.h>
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
// define clock parameter to rtc
RTC_DS1307 RTC;
//Special diplay characters defined
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t smiley[8] = {0x0,0x0,0x1f,0x15,0x1f,0x11,0x1f};
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t nocheck[8] = {0x0,0x1b,0xa,0x4,0xa,0x1b,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t arrowup[8] = {0x0,0x4,0xe,0x1f,0x4,0x4,0x4};
uint8_t arrowdown[8] = {0x0,0x4,0x4,0x4,0x1f,0xe,0x4};
uint8_t degree[8] = {0xc,0x12,0x12,0xc,0x0,0x0,0x0};
// set the LCD address to 0x27 for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x27,20,4);
//Temperature probe definitions
int DS18S20_Pin = 2; //assign DS18S20 outup wire to digital input pin 2
OneWire ds(DS18S20_Pin); // Data collection temperature via OneWire on digital pin 2
//pH probe definitions
#define pH_Pin 0 //pH meter Analog output to Analog Input 0
// SSR pin definitions
#define relay_1 8 //TL lights lights reserved
#define relay_2 7 // Airpump reserved
#define co2_pump 11
#define heater 3
// level pin definition
#define level 4
//define LED test pin
#define Beeper 13
//define capacitive sensor pins
CapacitiveSensor Tlcd = CapacitiveSensor(10,12);
float Tset=24.5; //variable for Fishtank temperature
float Toffset=0.2; //variable to determine water temerature variation
float Tmin=30.0; //variable with overrated value for first lowest temp measurement
float Tmax=15.0; //variable with underrated value for first highest temp measurement
float Tlow_alarm=21.0; //variable for alarm when water temp is to low
float Thigh_alarm=27.0; //variable for alarm hen water temp is to high
int wlevel=0; // variable for waterlevel detection
float pH_offset=0.12; //offset for pH probe to get pH of 7.00
//Main Program initialization
void setup(void) {
Serial.begin(9600);
// initialize I2C bus
Wire.begin();
//initialize clock
RTC.begin();
//Synchromise Arduino internal clock with RTC
setSyncProvider(syncProvider); //reference our syncProvider function instead of RTC_DS1307::get()
RTC.now();
// following line sets the RTC to the date & time this sketch was compiled
//RTC.adjust(DateTime(__DATE__, __TIME__));
// RTC.adjust(DateTime(2015, 12, 31, 14, 22, 0));
//Time when co2 pump switches ON and OFF
Alarm.alarmRepeat(9,0,0, CO_on); // 23:30 every day on
Alarm.alarmRepeat(23,0,0, CO_off); // 19:00 every day off
//Time when TL lights switches ON and OFF
Alarm.alarmRepeat(16,30,0, TL_on); // 16:30 every day on
Alarm.alarmRepeat(23,30,0, TL_off); // 23:30 every day off
//define relais pinmodes and initial states
pinMode (relay_1,OUTPUT);
pinMode (relay_2,OUTPUT);
digitalWrite (relay_1,LOW);
digitalWrite (relay_2,LOW);
//define solenoid pinmodes and intial states
pinMode (co2_pump,OUTPUT);
pinMode (heater,OUTPUT);
digitalWrite (co2_pump,LOW);
digitalWrite (heater,LOW);
//define level pinmode and state
pinMode (level,INPUT);
//define Test LED pinmode and initial state
pinMode (Beeper,OUTPUT);
digitalWrite (Beeper,LOW);
// Initialize the display
lcd.init();
lcd.backlight();
//assign special characters to var
lcd.createChar(0, bell);
lcd.createChar(1, smiley);
lcd.createChar(2, clock);
lcd.createChar(3, arrowdown);
lcd.createChar(4, arrowup);
lcd.createChar(5, check);
lcd.createChar(6, nocheck);
lcd.createChar(7, degree);
lcd.home();
// opening screen on power up
lcd.setCursor(0, 0);
for(int i = 0;i < 20; i++) lcd.printByte(1);
lcd.setCursor (0, 1);
lcd.print(" Fish Tank Control");
lcd.setCursor (0, 2);
lcd.print(" Guus Seegers");
lcd.setCursor(0, 3);
for(int i = 0;i < 20; i++) lcd.printByte(1);
delay (3000); //showtime
lcd.clear();
lcd.home();
// Build static part of display
// First display line watertmperature and clock
lcd.setCursor(0, 0);
lcd.print("Temp:");
lcd.setCursor(9, 0);
lcd.printByte(7);
lcd.setCursor(10,0);
lcd.print("C ");
//second display line static values start here
lcd.setCursor(0,1);
lcd.print("T-:");
lcd.setCursor(7,1);
lcd.printByte(7);
lcd.print("C ");
lcd.print("T+:");
lcd.setCursor(18,1);
lcd.printByte(7);
lcd.print("C");
//third display line static values start here
lcd.setCursor(0, 2);
lcd.print("pH:");
lcd.setCursor(8,2);
lcd.print("O2:");
lcd.printByte(6); //remove when Relay1 gets a function
lcd.setCursor(14,2);
lcd.print("Lit:");
TL_on(); //On power up ilumination always on
//fourth display line static values start here
lcd.setCursor(0,3);
lcd.print("Htr:");
lcd.setCursor(7,3);
lcd.print("CO2:");
CO_on(); //On power-up turn CO2 pump always on
lcd.setCursor(14,3);
lcd.print("Lvl:");
Alarm.timerOnce(30,LCDlightoff); //display for 30 seconds before turning backlight off
}
// create a sync. provider variable and load with unixtime
time_t syncProvider() //this does the same thing as RTC_DS1307::get()
{
return RTC.now().unixtime();
}
// Main Program loop
void loop(void) {
digitalClockDisplay(); //prepare RTC time for displaying
Alarm.delay(1000); // wait one second between clock display
WaterLevel(); //check waterlevel
LCDSensor(); //call LCD sensor check
// dynamic display section, shows live measurement values
float temperature = getTemp(); //read result from getTemp subroutine
Serial.print("Water-temperatuur: "); //print temp value on serial monitor
Serial.println(temperature);
lcd.setCursor(5,0); //set display cursor on target col-5 row-1
lcd.print(temperature,1); //display temp value with only 1 decimal
// determine lowest temperature and put it on display
if (temperature <= Tmin) {
Tmin=temperature;
}
// determine highest temperature and put it on display
if (temperature >= Tmax) {
Tmax=temperature;
}
lcd.setCursor(3,1);
lcd.print(Tmin,1);
lcd.setCursor(14,1);
lcd.print(Tmax,1);
//heater control water temperature with hysteresis check
if (temperature <= (Tset-Toffset)) {
digitalWrite (heater,HIGH);
lcd.setCursor(4,3);
lcd.printByte(5);
}
if (temperature >= Tset) {
digitalWrite (heater,LOW);
lcd.setCursor(4,3);
lcd.printByte(6);
}
// water alarm checks
if (temperature<=Tlow_alarm) {
Alarmloop();
Serial.println ("Watertemp is too low !");
}
if (temperature>=Thigh_alarm) {
Alarmloop();
Serial.println("Watertemp is too high");
}
//Subroutines from here
float pH=getpH(); //read result from pH subroutine getpH
Serial.print("pH-waarde: "); //print pH value on serial monitor
Serial.println(pH);
lcd.setCursor(3,2); // set display cursor on target col-15 row-1
// avoid display overflow by limiting a max of 3 characters and a decimal point as value
if( (pH > 10.00)&&(pH <= 14.00)){
lcd.print(pH,1); // display pH value with 1 decimal
} else
if (pH > 14.00) {
lcd.print ("n/c ");
} else
{lcd.print(pH,2); // display pH value with 2 decimals
}
delay(1000); //delay between temperature and pH measurements in msec
}
//Temperature probe subroutine section - measurement reading and conversion
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire:rc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
// put value in getTemp() variable
return TemperatureSum;
}
//pH probe subroutine section - measurement and conversion
float getpH(){
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;
for (int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf=analogRead(pH_Pin);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf>buf[j])
{
temp=buf;
buf=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf;
float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
phValue=3.5*phValue+pH_offset; //convert the millivolt into pH value
// put value in getpH() variable
return phValue;
}
void digitalClockDisplay()
{
// display date and time
// DateTime now = RTC.now();
lcd.setCursor(14,0);
lcd.printByte(2);
lcd.setCursor(15,0);
print2digits(hour());
lcd.print(":");
print2digits(minute());
//Serial time check
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void print2digits(int number) {
// Subroutine for Output leading zero date and time format LCD
if (number >= 0 && number < 10) {
lcd.write ('0');
}
lcd.print(number);
}
// Subroutine for Output leading zero date and time format Serial Monitor
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
// Subroutine to turn CO2 pump on
void CO_on(){
digitalWrite (co2_pump,HIGH);
lcd.setCursor(11,3);
lcd.printByte(5);
Serial.println("CO2 pump is on");
}
//Subroutine to turn CO2 pump off
void CO_off(){
digitalWrite (co2_pump,LOW);
lcd.setCursor(11,3);
lcd.printByte(6);
Serial.println("CO2 pump is off");
}
//Subroutine for waterlevel check
void WaterLevel(){
int wlevel=digitalRead (level);
if (wlevel==1) {
lcd.setCursor(18,3);
lcd.printByte(5);
Serial.println ("Waterlevel is OK");
}
else {
lcd.setCursor(18,3);
lcd.printByte(6);
Serial.println("Waterlevel is too low"); }
}
//Subroutine for LCD touchsensor
void LCDSensor() {
long start = millis();
long total = Tlcd.capacitiveSensor(30);
//Serial.print(millis() - start); // check on performance in milliseconds
//Serial.print("\t"); // tab character for debug window spacing
Serial.println(total); // print sensor output sensitivity
if (total > 5000) {
lcd.backlight(); //turn LCD backlight on for 60 seconds
Alarm.timerOnce (60,LCDlightoff);}
}
//Subroutine for TL lights are on
void TL_on(){
digitalWrite (relay_1,HIGH);
lcd.setCursor(18,2);
lcd.printByte(5);
Serial.println("Lights are on");
}
//Subroutine for TL lights are off
void TL_off(){
digitalWrite (relay_1,LOW);
lcd.setCursor(18,2);
lcd.printByte(6);
Serial.println("Lights are off");
}
//Subroutine for beeper alarm
void Alarmloop() {
digitalWrite(Beeper,HIGH);
delay (1000);
digitalWrite(Beeper,LOW);
}
//Subroutine to turn LCD-backlight off
void LCDlightoff() {
lcd.noBacklight();
}
//end of void loops
/*
The setup function runs once when you press reset or power the board
int CO2Klep =4;
int LED = 7;
int PhElec = 0; // potentiometer wiper (middle terminal) connected to analog pin 3
int Phwaarde = 0;
int Phscherm = 0;
int Phinstpod = 1;
int Phinst = 0;
int Phinstscherm = 0;
const byte pHpin = A2; // Connect the sensor's Po output to analogue pin 0.
float Po;
float a=.0294; // 7 = 495 4 = 393 a=3/(495-393).
float b=-7.553; // b=7-(r1*a) .
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// initialize digital pin 13 as an output.
pinMode(CO2Klep, OUTPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("GemetPh");
lcd.setCursor(0, 1);
lcd.print("inPh");
}
// the loop function runs over and over again forever
void loop() {
{
Po = (1023 - analogRead(pHpin)) ;
Serial.print("Raw: ");
Serial.print(Po, 2); // Print the result in the serial monitor.
Serial.print(", ph =");
Po=Po*a+b;
Serial.println(Po, 2); // print ph
delay(1000); // Take 1 reading per second.
}
Phscherm = map(Phwaarde, 0, 1023, 0, 14);
Phwaarde = analogRead(PhElec); // read the input pin
Serial.println(Phscherm); // print as an ASCII-encoded decimal
Phinstscherm = map (Phinst, 0, 1023, 0,14);
Phinst = analogRead (Phinstpod);
lcd.setCursor(9, 1);
lcd.print(Phinstscherm);
Serial.println(Phinst);
{
lcd.setCursor(9, 0);
lcd.print(Po);
lcd.print(" ");
if(Po < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (Po > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}
}
}
/*
if(pHValue < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (pHValue > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
lcd.begin (16,2); // <<----- My LCD was 16x2
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.home (); // go home
lcd.print("SainSmartI2C16x2");
}
void loop()
{
// Backlight on/off every 3 seconds
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print(n++,DEC);
lcd.setBacklight(LOW); // Backlight off
delay(3000);
lcd.setBacklight(HIGH); // Backlight on
delay(3000);
}
// the setup function runs once when you press reset or power the board
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
int CO2Klep =4;
int LED = 7;
int PhElec = 0; // potentiometer wiper (middle terminal) connected to analog pin 3
int Phwaarde = 0;
int Phscherm = 0;
int Phinstpod = 1;
int Phinst = 0;
int Phinstscherm = 0;
const byte pHpin = A2; // Connect the sensor's Po output to analogue pin 0.
float Po;
float a=.0294; // 7 = 495 4 = 393 a=3/(495-393).
float b=-7.553; // b=7-(r1*a) .
void setup() {
// initialize digital pin 13 as an output.
pinMode(CO2Klep, OUTPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
/*lcd.setCursor(0, 0);*/
lcd.home ();
lcd.print("GemetPh");
lcd.setCursor(0, 1);
lcd.print("inPh");
}
// the loop function runs over and over again forever
void loop() {
{
Po = (1023 - analogRead(pHpin)) ;
Serial.print("Raw: ");
Serial.print(Po, 2); // Print the result in the serial monitor.
Serial.print(", ph =");
Po=Po*a+b;
Serial.println(Po, 2); // print ph
delay(1000); // Take 1 reading per second.
}
Phscherm = map(Phwaarde, 0, 1023, 0, 14);
Phwaarde = analogRead(PhElec); // read the input pin
Serial.println(Phscherm); // print as an ASCII-encoded decimal
Phinstscherm = map (Phinst, 0, 1023, 0,14);
Phinst = analogRead (Phinstpod);
lcd.setCursor(9, 1);
lcd.print(Phinstscherm);
Serial.println(Phinst);
{
lcd.setCursor(9, 0);
lcd.print(Po);
lcd.print(" ");
if(Po < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (Po > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}
}
}
/*
if(pHValue < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (pHValue > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}*/
// the setup function runs once when you press reset or power the board
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int n = 1;
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
#include <Keypad.h>
const byte ROWS = 5; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'A','B','#','*'},
{'1','2','3', 'C'},
{'4','5','6', 'D'},
{'7','8','9', 'E'},
{'L','0','R' , 'R'}
};
byte rowPins[ROWS] = {12, 11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int CO2Klep =2;
int LED = 3;
int PhElec = 0; // potentiometer wiper (middle terminal) connected to analog pin 3
int Phwaarde = 0;
int Phscherm = 0;
int Phinstpod = 1;
int Phinst = 0;
int Phinstscherm = 0;
const byte pHpin = A2; // Connect the sensor's Po output to analogue pin 0.
float Po;
float a=.0294; // 7 = 495 4 = 393 a=3/(495-393).
float b=-7.553; // b=7-(r1*a) .
String msg = "";
OneWire ds(13); // on pin 2 (a 4.7K resistor is necessary)
void setup() {
// initialize digital pin 13 as an output.
pinMode(CO2Klep, OUTPUT);
pinMode(LED, OUTPUT);
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
lcd.begin(16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
/*lcd.setCursor(0, 0);*/
lcd.home ();
lcd.print("GemetPh");
lcd.setCursor(0, 1);
lcd.print("Temp");
kpd.setDebounceTime(1);
unsigned long loopCount = 0;
String msg = "";
}
// the loop function runs over and over again forever
void loop() {
//{
Po = (1023 - analogRead(pHpin)) ;
Serial.print("Raw: ");
Serial.print(Po, 2); // Print the result in the serial monitor.
Serial.print(", ph =");
Po=Po*a+b;
Serial.println(Po, 2); // print ph
delay(1000); // Take 1 reading per second.
//}
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
Serial.println("No more addresses.");
Serial.println();
ds.reset_search();
delay(250);
return;
}
Serial.print("ROM =");
for( i = 0; i < 8; i++) {
Serial.write(' ');
Serial.print(addr, HEX);
}
if (OneWire:rc8(addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return;
}
Serial.println();
// the first ROM byte indicates which chip
switch (addr[0]) {
case 0x10:
Serial.println(" Chip = DS18S20"); // or old DS1820
type_s = 1;
break;
case 0x28:
Serial.println(" Chip = DS18B20");
type_s = 0;
break;
case 0x22:
Serial.println(" Chip = DS1822");
type_s = 0;
break;
default:
Serial.println("Device is not a DS18x20 family device.");
return;
}
ds.reset();
ds.select(addr);
ds.write(0x44); // start conversion, use ds.write(0x44,1) with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
Serial.print(" Data = ");
Serial.print(present, HEX);
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
Serial.print(data, HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print(OneWire:rc8(data, 8), HEX);
Serial.println();
// Convert the data to actual temperature
// because the result is a 16 bit signed integer, it should
// be stored to an "int16_t" type, which is always 16 bits
// even when compiled on a 32 bit processor.
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
//// default is 12 bit resolution, 750 ms conversion time
}
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
Serial.print(" Temperature = ");
Serial.print(celsius);
Serial.print(" Celsius, ");
Serial.print(fahrenheit);
Serial.println(" Fahrenheit");
Phscherm = map(Phwaarde, 0, 1023, 0, 14);
Phwaarde = analogRead(PhElec); // read the input pin
Serial.println(Phscherm); // print as an ASCII-encoded decimal
Phinstscherm = map (Phinst, 0, 1023, 0,14);
Phinst = analogRead (Phinstpod);
lcd.setCursor(9, 1);
lcd.print(celsius);
Serial.println(Phinst);
{
lcd.setCursor(9, 0);
lcd.print(Po);
lcd.print(" ");
if(Po < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (Po > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}
} if (kpd.getKeys())
{
for (int i=0; i<LIST_MAX; i++) // Scan the whole key list.
{
if ( kpd.key.stateChanged ) // Only find keys that have changed state.
{
switch (kpd.key.kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
case PRESSED:
msg = " PRESSED.";
break;
case HOLD:
msg = " HOLD.";
break;
case RELEASED:
msg = " RELEASED.";
break;
case IDLE:
msg = " IDLE.";
}
Serial.print("Key ");
Serial.print(kpd.key.kchar);
Serial.println(msg);
}
}
}
}
/*
if(pHValue < 100){
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
}
if (pHValue > 105){
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
// wait for a second
}*/
Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.