Hi!
I hope this is not in the wrong forumpart, please direct me to correct one if that is the case.
First some background info may be interesting.
I am rather new to programming in general and to arduino, but i think i have som basic knowledge in how programming and electronics works, and i have been fiddling a bit with arduino the past month or so and i think i have come a bit on the way.
This is my first "serious" project on arduino, and it is to create a ceramic kiln controller with ramping, hold and continue fases. I have borrowed some code from different sketches and are trying to modify it to suit my needs, but i have run into problems now. The thing i am trying to accomplish is to use the code from Meltinator 9000 but use it with my shield that uses analogbottons on A0 instead of the shild from adafruit he is using, but i really don't know how define the "buttons" class now, and i get the folloving errors when i try to compile:
Sorry if i am not folloing forum rules correctly, i am still learning, please bear with me, i had to cut the code becuase it is on 20000 characters, how do i attach such a "big" sketch?
Sincerley
Parkeringskungen from sweden
odd.ino:105:1: error: ‘buttons’ does not name a type
odd.ino: In function ‘void loop()’:
odd.ino:150:3: error: ‘buttons’ was not declared in this scope
odd.ino:150:26: error: expected primary-expression before ‘.’ token
#include <Wire.h>
// #include <Adafruit_MCP23017.h>
// #include <Adafruit_RGBLCDShield.h>
#include <EEPROM.h>
#include "Adafruit_MAX31855.h"
#include <LiquidCrystal.h>
//#include <DFR_Key.h>
#include "AnalogButtons.h"
int thermoDO = 3;
int thermoCS = 4;
int thermoCLK = 5;
Adafruit_MAX31855 thermocouple(thermoCLK, thermoCS, thermoDO);
// Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int state = 1;
//The states are as follows:
// 1: navigation - Main Menu
// 2: Navigation - Run Menu
// 3: Navigation - Edit Menu
// 4: editing an existing program
// 5: running
// 6: Creating a new program
int currStep = 1; //This is the program step currently being edited.
int currCharVal = 65; //This integer will be used to cycle through characters when the user names a new program.
int statechange = 1;
int cursorHoriz = 1; //This is the horizontal cursor location.
int cursorVert = 1; //This is the certical cursor location.
int currentProg = 1; //This is the currrently selected program.
int currentActualTemp = 70; //The current actual temperature.
int currentTargetTemp = 70; //This is the current target temperature;
int tempUpdateDelay = 3000; //This is the time between relay actions in milliseconds.
int eepromAddress = 0;
byte numProgs; //This is the total number of stored programs, written to the first byte of the EEPROM memory.
char name1[11] = " "; //This is the name of the currently selected program
char name2[11] = " "; //This is the name of the program after the currently selected program
char newName[11] = " ";
unsigned long progStartTime;
unsigned long currTime;
double elapsed = 0;
double currTemp = 0;
double planTemp = 0;
byte Tmp = 0; //Temperature in tens of degrees Celcius
byte Rte = 0; //Rate in tens of degrees per hour
byte Hld = 0; //Hold time in minutes
int prgStart = 0; //This is the initial memory address of the currently selected program
int heatIncreaseFlag = 1;
int currStage = 0;
double currInitTemp = 0;
double currTgtTemp = 0;
int currRate = 0;
unsigned long currStageStartTime = 0;
unsigned long currRunTime = 0;
int currStageState = 3; //1 = heating, 2 = holding, 3 = stage finished
unsigned long currHoldTime = 0;
//double currTemp = 0;
unsigned long holdStartTime = 0;
int runflag = 0;
//I'll use pin 13 for the relay controller, because it already has an indicator LED on the Arduino UNO board.
// #define WHITE 0x7
//DFR_Key keypad;
#define ANALOG_PIN 0
void handleButtons(int id, boolean held);
AnalogButtons analogButtons(ANALOG_PIN, 30, &handleButtons);
Button BUTTON_LEFT = Button(1, 1013,1014);
Button BUTTON_RIGHT = Button(2, 1002, 1002);
Button BUTTON_SELECT = Button(3, 970, 971);
Button BUTTON_UP = Button(4, 929, 933);
Button BUTTON_DOWN = Button(5, 860, 875);
//int localKey = 0;
String keyString = "";
void setup() {
// Debugging output
Serial.begin(9600);
pinMode(13, OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
//int time = millis();
lcd.print("MELTINATOR 9000 ");//("Initializing...");
lcd.setCursor(0,1);
lcd.print("LezBurnSumStuff!");
delay(2000);
//time = millis() - time;
//Serial.print("Took "); Serial.print(time); Serial.println(" ms");
// lcd.setBacklight(WHITE);
}
// uint8_t i=0;
void loop() {
//Serial.begin(9600);
//Serial.print("Iteration...\n");
//Serial.print(state);
//Serial.print("\n");
//Serial.print(runflag);
//Serial.print("\n");
Serial.print(currStageState);
Serial.print("\n");
Serial.print(currTgtTemp);
Serial.print("\n");
Serial.print(currRate);
Serial.print("\n");
Serial.print(currRunTime);
Serial.print("\n");
Serial.print(currInitTemp);
Serial.print("\n");
Serial.print(planTemp);
Serial.print("\n");
Serial.print("\n");
//This first "if" loop is to allow the loop to run freely if the program is in the "run" state (5).
//if (state!=5) {
// uint8_t buttons = lcd.readButtons();
buttons = AnalogButtons.checkButtons();
//}
//else {
// uint8_t buttons = 1;
// statechange = 1;
//}
if ((buttons)||(state==5)) {
runflag = 1;
}
else {
runflag = 0;
}
if ((runflag)||(statechange)) {
//if ((buttons)||(statechange)) {
statechange = 0;
switch (state) {
case 1:
//State:Navigation - Main Menu
//Draw the Main Menu screen
lcd.clear();
lcd.setCursor(0,0);
//lcd.blink();
lcd.print("Main Menu ");
lcd.setCursor(0,1);
switch (cursorHoriz) {
case 1:
lcd.print("*Run _Edit _New ");
break;
case 2:
lcd.print("_Run *Edit _New ");
break;
case 3:
lcd.print("_Run _Edit *New ");
break;
}
//Place the cursor in the appropriate location
//Allow the user to move the cursor location and press enter.
if (buttons) {
if (buttons & BUTTON_LEFT) {
cursorHoriz = cursorHoriz - 1;
statechange = 1;
}
if (buttons & BUTTON_RIGHT) {
cursorHoriz = cursorHoriz + 1;
statechange = 1;
}
//Keep the cursor location valid:
cursorHoriz = constrain(cursorHoriz,1,3);