/*
* Menu code based on EEEnthusiast Arduino LCD Display Menu System
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// TEMP SENSOR PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is conntec to the Arduino digital pin 21
#define ONE_WIRE_BUS 21
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// GRIPPER PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define gripperServ 53
#include <Servo.h>
Servo Myservo;
int gripperServPos=0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// WATER LEVEL SENSOR ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define waterlvl A8
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// ECHO SENSOR PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define trigPin 34
#define echoPin 36
float duration, distance;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// LED PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define blueLed 52
#define greenLed 50
#define redLed 48
#define yellowLed 46
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// MOTOR PIN ASSIGNMENT ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Acceleration Library
#include <AccelStepper.h> //////////--STEPPER LIBRARY--/////////
#include <MultiStepper.h>
//Limit Switch Pins
#define Xplus 9
//Stepper Travel variables
long HomingX = -1;
long HomingX2 = 1;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// TEMP SENSOR ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <DHT.h>
//Arduino pin connected to the DHT-11 data pin
#define DHTPIN 22
//type of DHT Sensor
#define DHTTYPE DHT11
//Initialize DHT Sensor
DHT dht(DHTPIN, DHTTYPE);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// STEPPER MOTOR LOGIC ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Motor Pins
#define StepX 2
#define DirX 5
#define StepY 3
#define DirY 6
//X axis motors
AccelStepper stepperX(1,2,5); //1 = Easydriver setting
//Pin 2 for StepX
//Pin 5 for Direction
AccelStepper stepperX2(1,3,6); //1 = Easydriver setting
//Pin 3 for StepX
//Pin 6 for Direction
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// LCD LOGIC AND PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// SAVE PARAMETERS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int spacingX1 = 20;
int spacingY1 = 20;
int watering1 = 4;
int light1 = 12;
int temp1 = 60;
int spacingX2 = 25;
int spacingY2 = 25;
int watering2 = 5;
int light2 = 8;
int temp2 = 65;
int spacingX3 = 30;
int spacingY3 = 30;
int watering3 = 6;
int light3 = 8;
int temp3 = 70;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// INPUT LOGIC ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Input & Button Logic
const int numOfInputs = 6;
const int inputPins[numOfInputs] = {22,24,26,28,30,32};
int inputState[numOfInputs];
int lastInputState[numOfInputs] = {LOW,LOW,LOW,LOW,LOW};
bool inputFlags[numOfInputs] = {LOW,LOW,LOW,LOW,LOW};
long lastDebounceTime[numOfInputs] = {0,0,0,0,0,0};
long debounceDelay = 5;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// POSSIBLE SCEEN TEXT ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char menu_000[] = "Start"; // 0
const char menu_100[] = "Edit File"; // 1
const char menu_101[] = "Gripper Control "; // 2
const char menu_102[] = "Current Soil Temp "; // 3
const char menu_103[] = "Current Board Temp "; // 4
const char menu_104[] = "Seeding "; // 5
const char menu_105[] = "Start Cycle "; // 6
const char menu_106[] = "Seed Level"; // 7
const char menu_107[] = "Water Level "; // 8
const char menu_200[] = "SAVE FILE 1 "; // 9
const char menu_201[] = "SAVE FILE 2 "; // 10
const char menu_202[] = "SAVE FILE 3 "; // 11
const char menu_203[] = "SAVE FILE 4 "; // 12
const char menu_300[] = "Spacing X SF1"; // 13
const char menu_301[] = "Spacing Y SF1"; // 14
const char menu_302[] = "Watering T SF1"; // 15
const char menu_303[] = "Light Cycle SF1"; // 16
const char menu_304[] = "Temperature SF1"; // 17
const char menu_400[] = "Spacing X SF2"; // 18
const char menu_401[] = "Spacing Y SF2"; // 19
const char menu_402[] = "Watering T SF2"; // 20
const char menu_403[] = "Light Cycle SF2"; // 21
const char menu_404[] = "Temperature SF2"; // 22
const char menu_500[] = "Spacing X SF3"; // 23
const char menu_501[] = "Spacing Y SF3"; // 24
const char menu_502[] = "Watering T SF3"; // 25
const char menu_503[] = "Light Cycle SF3"; // 26
const char menu_504[] = "Temperature SF3"; // 27
const char menu_600[] = "Spacing X SF4"; // 28
const char menu_601[] = "Spacing Y SF4"; // 29
const char menu_602[] = "Watering T SF4"; // 30
const char menu_603[] = "Light Cycle SF4"; // 31
const char menu_604[] = "Temperature SF4"; // 32
const char menu_700[] = " WATER LEVEL"; // 33
const char menu_701[] = " SEED LEVEL"; // 34
const char menu_702[] = "EMERGENCY STOP"; // 35
const char unit_000[] = " "; // UNIT
const char unit_001[] = "mm "; // UNIT
const char unit_002[] = "hrs "; // UNIT
const char unit_003[] = "deg. F "; // UNIT
const char unit_004[] = " *WARNING* "; // UNIT
const char unit_005[] = " *CRITICAL* "; // UNIT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// MENU SCUCTURE ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef const struct MenuStructure{
const char *text;
const char *unit;
unsigned char page;
int save;
unsigned char edit;
void (*fp) (void);
} MenuEntry;
MenuEntry menu[] =
{
// page text, unit txt, page, save, edit, *f
{menu_000, unit_000, 0, 0, 0, 0}, // 0
{menu_100, unit_000, 1, 0, 0, 0}, // 1
{menu_101, unit_000, 1, 1, 0, 0}, // 2
{menu_102, unit_000, 1, 2, 0, 0}, // 3
{menu_103, unit_000, 1, 3, 0, 0}, // 4
{menu_104, unit_000, 1, 4, 0, 0}, // 5
{menu_105, unit_000, 1, 2, 0, 0}, // 6
{menu_106, unit_000, 1, 3, 0, 0}, // 7
{menu_107, unit_000, 1, 4, 0, 0}, // 8
{menu_200, unit_000, 2, 1, 0, 0}, // 9
{menu_201, unit_000, 2, 2, 0, 0}, // 10
{menu_202, unit_000, 2, 3, 0, 0}, // 11
{menu_203, unit_000, 2, 4, 0, 0}, // 12
{menu_300, unit_001, 3, spacingX1, 1, 0}, // 13
{menu_301, unit_001, 3, spacingY1, 1, 0}, // 14
{menu_302, unit_002, 3, watering1, 1, 0}, // 15
{menu_303, unit_002, 3, light1, 1, 0}, // 16
{menu_304, unit_003, 3, temp1, 1, 0}, // 17
{menu_400, unit_001, 4, spacingX2, 1, 0}, // 18
{menu_401, unit_001, 4, spacingY2, 1, 0}, // 19
{menu_402, unit_002, 4, watering2, 1, 0}, // 20
{menu_403, unit_002, 4, light2, 1, 0}, // 21
{menu_404, unit_003, 4, temp2, 1, 0}, // 22
{menu_500, unit_001, 5, 2, 1, 0}, // 23
{menu_501, unit_001, 5, 2, 1, 0}, // 24
{menu_502, unit_002, 5, 2, 1, 0}, // 25
{menu_503, unit_002, 5, 2, 1, 0}, // 26
{menu_504, unit_003, 5, 2, 1, 0}, // 27
{menu_600, unit_001, 6, 2, 1, 0}, // 28
{menu_601, unit_001, 6, 2, 1, 0}, // 29
{menu_602, unit_002, 6, 2, 1, 0}, // 30
{menu_603, unit_002, 6, 2, 1, 0}, // 31
{menu_604, unit_003, 6, 2, 1, 0}, // 32
{menu_700, unit_004, 7, 3, 2, 0}, // 33
{menu_701, unit_004, 7, 3, 2, 0}, // 34
{menu_702, unit_004, 7, 3, 2, 0}, // 35
{menu_700, unit_005, 7, 3, 2, 0}, // 36
{menu_701, unit_005, 7, 3, 2, 0}, // 37
{menu_702, unit_005, 7, 3, 2, 0}, // 38
};
int currentScreen = 0;
int currentPage = 0;
int prevScreen = currentScreen-1;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// SETUP ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
//*//*//*//*//*//LED PIN ASSINGMENT //*//*//*//*//*//
Myservo.attach(gripperServ);
//*//*//*//*//*//LED PIN ASSINGMENT //*//*//*//*//*//
pinMode(blueLed, OUTPUT); // sets LED1 as output
pinMode(greenLed, OUTPUT); // sets LED3 as output
pinMode(redLed, OUTPUT); // sets LED4 as output
pinMode(yellowLed, OUTPUT); // sets LED5 as output
//*//*//*//*//*//DISTANCE SENSOR PIN ASSIGNMENT //*//*//*//*//*//
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
//*//*//*//*//*//PUSH BUTTON PIN ASSIGNMENT //*//*//*//*//*//
for(int i = 0; i < numOfInputs; i++) {
pinMode(inputPins[i], INPUT);
digitalWrite(inputPins[i], HIGH); // pull-up 20k
}
//*//*//*//*//*//LCD START //*//*//*//*//*//
// initialize the LCD
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// LOOP ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
setInputFlags();
resolveInputFlags();
passiveSeedLevel();
passiveWaterLevel();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU INPUT FLAGS ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
int reading = digitalRead(inputPins[i]);
if (reading != lastInputState[i]) {
lastDebounceTime[i] = millis();
}
if ((millis() - lastDebounceTime[i]) > debounceDelay) {
if (reading != inputState[i]) {
inputState[i] = reading;
if (inputState[i] == HIGH) {
digitalWrite(blueLed, HIGH);
delay(250);
digitalWrite(blueLed, LOW);
inputFlags[i] = HIGH;
}
}
}
lastInputState[i] = reading;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU RESOLVE FLAG ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void resolveInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
if(inputFlags[i] == HIGH) {
inputAction(i);
inputFlags[i] = LOW;
printScreen();
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU INPUT ACTION ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void inputAction(int input) {
switch (menu[currentScreen].page){
case 0: //*//*//*//*//*//PAGE 0 START //*//*//*//*//*//
if (input == 4) {
currentScreen = 1;
} //*//*//*//*//*//PAGE 0 END //*//*//*//*//*//
break;
case 1: //*//*//*//*//*//PAGE 1 START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 8) {
currentScreen = 1;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 1) {
currentScreen = 8;
}
else{
currentScreen--;
}
}
else if (input == 4) {
if (currentScreen == 1){ ////////////PAGE UP TO NEXT SCREEN///////////
currentScreen = 6;
}
if (currentScreen == 2){ ////////////MANUAL GRIPPER CONTROL///////////
manualGripperCtrl();
}
if (currentScreen == 3){ /////////////DISPLAY CURRENT BOARD TEMP////////////
currentBoardTemp();
}
if (currentScreen == 4){ ////////////MANUAL SEEDING OPERATION///////////
}
if (currentScreen == 5){ ////////////START CYCLE///////////
}
}
else if (input == 5) { ////////////PAGE DOWN TO NEXT SCREEN///////////
currentScreen = 0;
}
//*//*//*//*//*//PAGE 1 END //*//*//*//*//*//
break;
case 2: //*//*//*//*//*// EDIT SCREN PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 12) {
currentScreen = 9;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 9) {
currentScreen = 12;
}
else{
currentScreen--;
}
}
else if (input == 4) { ////////////PAGE UP TO NEXT SCREEN///////////
if (currentScreen == 9){ ////////////PAGE UP TO SAVE 1///////////
currentScreen = 13;
}
if (currentScreen == 10){ ////////////PAGE UP TO SAVE 2///////////
currentScreen = 18;
}
if (currentScreen == 11){ /////////////PAGE UP TO SAVE 3////////////
currentScreen = 23;
}
if (currentScreen == 12){ ////////////PAGE UP TO SAVE 4////////////
currentScreen = 28;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//EDIT SCREN PAGE END //*//*//*//*//*//
break;
case 3: //*//*//*//*//*// SAVE FILE 1 PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 17) {
currentScreen = 13;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 13) {
currentScreen = 17;
}
else{
currentScreen--;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//SAVE FILE 1 PAGE END //*//*//*//*//*//
break;
case 4: //*//*//*//*//*// SAVE FILE 2 PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 22) {
currentScreen = 18;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 18) {
currentScreen = 22;
}
else{
currentScreen--;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//SAVE FILE 2 PAGE END //*//*//*//*//*//
break;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MANUAL GRIPPER CONROL ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void manualGripperCtrl(void);{
if(digitalRead(32) == LOW){
Myservo.write(135);
}
else
Myservo.write(180);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// PASSIVE SEED DISTANCE CHECKING ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void passiveSeedLevel() {
/*
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration= pulseIn(echoPin, HIGH);
//determine distance from duration
// use 343 meters per second as speed of sound
distance = (duration/ 2)*.0343;
if (distance >= 200){
currentScreen = 34;
digitalWrite(yellowLed, LOW);
}
if (distance <= 200){
currentScreen = 34;
digitalWrite(yellowLed, HIGH);
}
if (distance >= 50){
currentScreen = 37;
digitalWrite(redLed, LOW);
}
*/
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// PASSIVE WATER LEVEL CHECKING ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void passiveWaterLevel() {
// read the input on analog pin 0:
int value = analogRead(waterlvl);
if (value > 500) {
currentScreen = 0;
digitalWrite(yellowLed,LOW);
digitalWrite(redLed,LOW);
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
else if (value < 250 && value > 50) {
digitalWrite(yellowLed,HIGH);
digitalWrite(redLed,LOW);
currentScreen = 33;
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].unit);
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
else if (value < 50 && value < 250) {
currentScreen = 36;
digitalWrite(yellowLed,LOW);
digitalWrite(redLed,HIGH);
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].unit);
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU PRINT SCREEN ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void printScreen() {
switch (menu[currentScreen].edit){
case 0:
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
break;
case 1:
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].save);
lcd.print(" ");
lcd.print(menu[currentScreen].unit);
break;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU PRINT SCREEN ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void currentBoardTemp();{
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures();
lcd.print("Board Temp.");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(sensors.getTempFByIndex(0));
lcd.print("deg. F");
delay(10000);
currentScreen = 0;
- lose the semicolon
- look at the end of this function - something's missing!
the semicolon is there i didn't copy it over correctly error is still present`Preformatted text
/*
* 10/13/22
* Menu code based off EEEnthusiast Arduino LCD Display Menu System
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// TEMP SENSOR PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is conntec to the Arduino digital pin 21
#define ONE_WIRE_BUS 21
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// GRIPPER PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define gripperServ 53
#include <Servo.h>
Servo Myservo;
int gripperServPos=0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// WATER LEVEL SENSOR ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define waterlvl A8
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// ECHO SENSOR PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define trigPin 34
#define echoPin 36
float duration, distance;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// LED PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define blueLed 52
#define greenLed 50
#define redLed 48
#define yellowLed 46
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// MOTOR PIN ASSIGNMENT ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Acceleration Library
#include <AccelStepper.h> //////////--STEPPER LIBRARY--/////////
#include <MultiStepper.h>
//Limit Switch Pins
#define Xplus 9
//Stepper Travel variables
long HomingX = -1;
long HomingX2 = 1;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// TEMP SENSOR ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <DHT.h>
//Arduino pin connected to the DHT-11 data pin
#define DHTPIN 22
//type of DHT Sensor
#define DHTTYPE DHT11
//Initialize DHT Sensor
DHT dht(DHTPIN, DHTTYPE);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// STEPPER MOTOR LOGIC ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Motor Pins
#define StepX 2
#define DirX 5
#define StepY 3
#define DirY 6
//X axis motors
AccelStepper stepperX(1,2,5); //1 = Easydriver setting
//Pin 2 for StepX
//Pin 5 for Direction
AccelStepper stepperX2(1,3,6); //1 = Easydriver setting
//Pin 3 for StepX
//Pin 6 for Direction
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// LCD LOGIC AND PINS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// SAVE PARAMETERS ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int spacingX1 = 20;
int spacingY1 = 20;
int watering1 = 4;
int light1 = 12;
int temp1 = 60;
int spacingX2 = 25;
int spacingY2 = 25;
int watering2 = 5;
int light2 = 8;
int temp2 = 65;
int spacingX3 = 30;
int spacingY3 = 30;
int watering3 = 6;
int light3 = 8;
int temp3 = 70;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// INPUT LOGIC ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Input & Button Logic
const int numOfInputs = 6;
const int inputPins[numOfInputs] = {22,24,26,28,30,32};
int inputState[numOfInputs];
int lastInputState[numOfInputs] = {LOW,LOW,LOW,LOW,LOW};
bool inputFlags[numOfInputs] = {LOW,LOW,LOW,LOW,LOW};
long lastDebounceTime[numOfInputs] = {0,0,0,0,0,0};
long debounceDelay = 5;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// POSSIBLE SCEEN TEXT ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const char menu_000[] = "Start"; // 0
const char menu_100[] = "Edit File"; // 1
const char menu_101[] = "Gripper Control "; // 2
const char menu_102[] = "Current Soil Temp "; // 3
const char menu_103[] = "Current Board Temp "; // 4
const char menu_104[] = "Seeding "; // 5
const char menu_105[] = "Start Cycle "; // 6
const char menu_106[] = "Seed Level"; // 7
const char menu_107[] = "Water Level "; // 8
const char menu_200[] = "SAVE FILE 1 "; // 9
const char menu_201[] = "SAVE FILE 2 "; // 10
const char menu_202[] = "SAVE FILE 3 "; // 11
const char menu_203[] = "SAVE FILE 4 "; // 12
const char menu_300[] = "Spacing X SF1"; // 13
const char menu_301[] = "Spacing Y SF1"; // 14
const char menu_302[] = "Watering T SF1"; // 15
const char menu_303[] = "Light Cycle SF1"; // 16
const char menu_304[] = "Temperature SF1"; // 17
const char menu_400[] = "Spacing X SF2"; // 18
const char menu_401[] = "Spacing Y SF2"; // 19
const char menu_402[] = "Watering T SF2"; // 20
const char menu_403[] = "Light Cycle SF2"; // 21
const char menu_404[] = "Temperature SF2"; // 22
const char menu_500[] = "Spacing X SF3"; // 23
const char menu_501[] = "Spacing Y SF3"; // 24
const char menu_502[] = "Watering T SF3"; // 25
const char menu_503[] = "Light Cycle SF3"; // 26
const char menu_504[] = "Temperature SF3"; // 27
const char menu_600[] = "Spacing X SF4"; // 28
const char menu_601[] = "Spacing Y SF4"; // 29
const char menu_602[] = "Watering T SF4"; // 30
const char menu_603[] = "Light Cycle SF4"; // 31
const char menu_604[] = "Temperature SF4"; // 32
const char menu_700[] = " WATER LEVEL"; // 33
const char menu_701[] = " SEED LEVEL"; // 34
const char menu_702[] = "EMERGENCY STOP"; // 35
const char unit_000[] = " "; // UNIT
const char unit_001[] = "mm "; // UNIT
const char unit_002[] = "hrs "; // UNIT
const char unit_003[] = "deg. F "; // UNIT
const char unit_004[] = " *WARNING* "; // UNIT
const char unit_005[] = " *CRITICAL* "; // UNIT
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ///////////////////////////////////
//////////////////////////// MENU SCUCTURE ////////////////////////////////////
//////////////////////////// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef const struct MenuStructure{
const char *text;
const char *unit;
unsigned char page;
int save;
unsigned char edit;
void (*fp) (void);
} MenuEntry;
MenuEntry menu[] =
{
// page text, unit txt, page, save, edit, *f
{menu_000, unit_000, 0, 0, 0, 0}, // 0
{menu_100, unit_000, 1, 0, 0, 0}, // 1
{menu_101, unit_000, 1, 1, 0, 0}, // 2
{menu_102, unit_000, 1, 2, 0, 0}, // 3
{menu_103, unit_000, 1, 3, 0, 0}, // 4
{menu_104, unit_000, 1, 4, 0, 0}, // 5
{menu_105, unit_000, 1, 2, 0, 0}, // 6
{menu_106, unit_000, 1, 3, 0, 0}, // 7
{menu_107, unit_000, 1, 4, 0, 0}, // 8
{menu_200, unit_000, 2, 1, 0, 0}, // 9
{menu_201, unit_000, 2, 2, 0, 0}, // 10
{menu_202, unit_000, 2, 3, 0, 0}, // 11
{menu_203, unit_000, 2, 4, 0, 0}, // 12
{menu_300, unit_001, 3, spacingX1, 1, 0}, // 13
{menu_301, unit_001, 3, spacingY1, 1, 0}, // 14
{menu_302, unit_002, 3, watering1, 1, 0}, // 15
{menu_303, unit_002, 3, light1, 1, 0}, // 16
{menu_304, unit_003, 3, temp1, 1, 0}, // 17
{menu_400, unit_001, 4, spacingX2, 1, 0}, // 18
{menu_401, unit_001, 4, spacingY2, 1, 0}, // 19
{menu_402, unit_002, 4, watering2, 1, 0}, // 20
{menu_403, unit_002, 4, light2, 1, 0}, // 21
{menu_404, unit_003, 4, temp2, 1, 0}, // 22
{menu_500, unit_001, 5, 2, 1, 0}, // 23
{menu_501, unit_001, 5, 2, 1, 0}, // 24
{menu_502, unit_002, 5, 2, 1, 0}, // 25
{menu_503, unit_002, 5, 2, 1, 0}, // 26
{menu_504, unit_003, 5, 2, 1, 0}, // 27
{menu_600, unit_001, 6, 2, 1, 0}, // 28
{menu_601, unit_001, 6, 2, 1, 0}, // 29
{menu_602, unit_002, 6, 2, 1, 0}, // 30
{menu_603, unit_002, 6, 2, 1, 0}, // 31
{menu_604, unit_003, 6, 2, 1, 0}, // 32
{menu_700, unit_004, 7, 3, 2, 0}, // 33
{menu_701, unit_004, 7, 3, 2, 0}, // 34
{menu_702, unit_004, 7, 3, 2, 0}, // 35
{menu_700, unit_005, 7, 3, 2, 0}, // 36
{menu_701, unit_005, 7, 3, 2, 0}, // 37
{menu_702, unit_005, 7, 3, 2, 0}, // 38
};
int currentScreen = 0;
int currentPage = 0;
int prevScreen = currentScreen-1;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// SETUP ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
//*//*//*//*//*//LED PIN ASSINGMENT //*//*//*//*//*//
Myservo.attach(gripperServ);
//*//*//*//*//*//LED PIN ASSINGMENT //*//*//*//*//*//
pinMode(blueLed, OUTPUT); // sets LED1 as output
pinMode(greenLed, OUTPUT); // sets LED3 as output
pinMode(redLed, OUTPUT); // sets LED4 as output
pinMode(yellowLed, OUTPUT); // sets LED5 as output
//*//*//*//*//*//DISTANCE SENSOR PIN ASSIGNMENT //*//*//*//*//*//
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
//*//*//*//*//*//PUSH BUTTON PIN ASSIGNMENT //*//*//*//*//*//
for(int i = 0; i < numOfInputs; i++) {
pinMode(inputPins[i], INPUT);
digitalWrite(inputPins[i], HIGH); // pull-up 20k
}
//*//*//*//*//*//LCD START //*//*//*//*//*//
// initialize the LCD
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// LOOP ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
setInputFlags();
resolveInputFlags();
passiveSeedLevel();
passiveWaterLevel();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU INPUT FLAGS ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
int reading = digitalRead(inputPins[i]);
if (reading != lastInputState[i]) {
lastDebounceTime[i] = millis();
}
if ((millis() - lastDebounceTime[i]) > debounceDelay) {
if (reading != inputState[i]) {
inputState[i] = reading;
if (inputState[i] == HIGH) {
digitalWrite(blueLed, HIGH);
delay(250);
digitalWrite(blueLed, LOW);
inputFlags[i] = HIGH;
}
}
}
lastInputState[i] = reading;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU RESOLVE FLAG ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void resolveInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
if(inputFlags[i] == HIGH) {
inputAction(i);
inputFlags[i] = LOW;
printScreen();
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU INPUT ACTION ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void inputAction(int input) {
switch (menu[currentScreen].page){
case 0: //*//*//*//*//*//PAGE 0 START //*//*//*//*//*//
if (input == 4) {
currentScreen = 1;
} //*//*//*//*//*//PAGE 0 END //*//*//*//*//*//
break;
case 1: //*//*//*//*//*//PAGE 1 START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 8) {
currentScreen = 1;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 1) {
currentScreen = 8;
}
else{
currentScreen--;
}
}
else if (input == 4) {
if (currentScreen == 1){ ////////////PAGE UP TO NEXT SCREEN///////////
currentScreen = 6;
}
if (currentScreen == 2){ ////////////MANUAL GRIPPER CONTROL///////////
manualGripperCtrl();
}
if (currentScreen == 3){ /////////////DISPLAY CURRENT BOARD TEMP////////////
currentBoardTemp();
}
if (currentScreen == 4){ ////////////MANUAL SEEDING OPERATION///////////
}
if (currentScreen == 5){ ////////////START CYCLE///////////
}
}
else if (input == 5) { ////////////PAGE DOWN TO NEXT SCREEN///////////
currentScreen = 0;
}
//*//*//*//*//*//PAGE 1 END //*//*//*//*//*//
break;
case 2: //*//*//*//*//*// EDIT SCREN PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 12) {
currentScreen = 9;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 9) {
currentScreen = 12;
}
else{
currentScreen--;
}
}
else if (input == 4) { ////////////PAGE UP TO NEXT SCREEN///////////
if (currentScreen == 9){ ////////////PAGE UP TO SAVE 1///////////
currentScreen = 13;
}
if (currentScreen == 10){ ////////////PAGE UP TO SAVE 2///////////
currentScreen = 18;
}
if (currentScreen == 11){ /////////////PAGE UP TO SAVE 3////////////
currentScreen = 23;
}
if (currentScreen == 12){ ////////////PAGE UP TO SAVE 4////////////
currentScreen = 28;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//EDIT SCREN PAGE END //*//*//*//*//*//
break;
case 3: //*//*//*//*//*// SAVE FILE 1 PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 17) {
currentScreen = 13;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 13) {
currentScreen = 17;
}
else{
currentScreen--;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//SAVE FILE 1 PAGE END //*//*//*//*//*//
break;
case 4: //*//*//*//*//*// SAVE FILE 2 PAGE START //*//*//*//*//*//
if (input == 0) { ////////////SCREEN UP///////////
if (currentScreen == 22) {
currentScreen = 18;
}
else{
currentScreen++;
}
}
else if (input == 1) { ////////////SCREEN DOWN///////////
if (currentScreen == 18) {
currentScreen = 22;
}
else{
currentScreen--;
}
}
else if (input == 5) { ////////////PAGE DOWN TO LAST PAGE///////////
currentScreen = 0;
} //*//*//*//*//*//SAVE FILE 2 PAGE END //*//*//*//*//*//
break;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MANUAL GRIPPER CONROL ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void manualGripperCtrl(void);{
if(digitalRead(32) == LOW){
Myservo.write(135);
}
else
Myservo.write(180);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// PASSIVE SEED DISTANCE CHECKING ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void passiveSeedLevel() {
/*
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration= pulseIn(echoPin, HIGH);
//determine distance from duration
// use 343 meters per second as speed of sound
distance = (duration/ 2)*.0343;
if (distance >= 200){
currentScreen = 34;
digitalWrite(yellowLed, LOW);
}
if (distance <= 200){
currentScreen = 34;
digitalWrite(yellowLed, HIGH);
}
if (distance >= 50){
currentScreen = 37;
digitalWrite(redLed, LOW);
}
*/
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// PASSIVE WATER LEVEL CHECKING ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void passiveWaterLevel() {
// read the input on analog pin 0:
int value = analogRead(waterlvl);
if (value > 500) {
currentScreen = 0;
digitalWrite(yellowLed,LOW);
digitalWrite(redLed,LOW);
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
else if (value < 250 && value > 50) {
digitalWrite(yellowLed,HIGH);
digitalWrite(redLed,LOW);
currentScreen = 33;
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].unit);
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
else if (value < 50 && value < 250) {
currentScreen = 36;
digitalWrite(yellowLed,LOW);
digitalWrite(redLed,HIGH);
delay(1000);
lcd.clear();
lcd.print(menu[currentScreen].unit);
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].text);
lcd.print(" ");
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU PRINT SCREEN ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void printScreen() {
switch (menu[currentScreen].edit){
case 0:
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
break;
case 1:
lcd.clear();
lcd.print(menu[currentScreen].text);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(menu[currentScreen].save);
lcd.print(" ");
lcd.print(menu[currentScreen].unit);
break;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////// //// //// ///////////////////////////////////
/////////////////////////////////// MENU PRINT SCREEN ////////////////////////////////////
////////////////////////////////// //// //// ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void currentBoardTemp();{
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures();
lcd.print("Board Temp.");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print(sensors.getTempFByIndex(0));
lcd.print("deg. F");
delay(10000);
currentScreen = 0;
}
it is not the only such error....
I said Lose the semicolon, as in DELETE it. B707 is correct, but I was hoping you'd twig to that after the first one.
interesting condition ![]()
and this
Your copy-paste error wasn't necessary, in the IDE there's a function (ctrl-shft-C) which copies your entire code so you can paste it into your message box correctly. AFTER you format it with ctrl-T, of course.
ohhh ; not {.
Thank you it compiled ![]()
really?
I copied the code you posted and there were mutliple additional errors
lcd.init() instead of lcd.begin()
a missing closing curly brace
best regards Stefan