Hi All,
I have to advise I am not very good at coding but I have been successful so far. I need a little help to find a Simple Menu sketch that uses clickencoder.h, liquidecrystal.h. It will run on Mega2560 for now but eventually run on a NANO.
I Have found many examples but find that they all are different or use different ways of getting menu's or input devices. Am hoping I can find something that would be simple for me to change as my skills in programming are limited although this will certainly help me get more skills.
Basic Menu would be:
Charge
Discharge
Gas Gauge
Shutdown
As an example this code would run in Charge mode in a loop. All of them would be similar. Disregard Serial portion as it would not be need. Eventually I would need to break out the last 2 Bytes to extract some ADC measurements and display on LCD but that will be for another thread and time. Baby steps I guess
Thank you very much in advance
Luca
#include <SPI.h>
//Set CS_Pin
const int CS_Pin = 49;
//Set Variables
int incomingByte1;
int incomingByte2;
int incomingByte3;
int incomingByte4;
int incomingByte5;
int incomingByte6;
void setup() {
// set the slaveSelectPin as an output:
pinMode(CS_Pin, OUTPUT);
pinMode(53, OUTPUT); //Insure Mega is Master
digitalWrite(CS_Pin, HIGH); // Activate the CS line (CS is active High)
//Initalize SPI
SPI.begin();
SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0));
//Initialize Serial
Serial.begin(9600);
//Let things stabalize
delay(100);
}
void loop() {
//Loop Write-Read from LTC1325
// Set CS Pin LOW
digitalWrite(CS_Pin, LOW); // Activate the CS line (CS is active LOW)
delay(100);
//Send 6 Bytes
SPI.transfer(0b00000010); // Send First byte
delay(1);
//incomingByte1 = SPI.transfer(0); // get RXbyte1 result and place in incomingByte 1
//Serial.println("Byte1");
//Serial.println(incomingByte1);
SPI.transfer(0b00100100); // Send Second byte
delay(1);
//incomingByte2 = SPI.transfer(0); // get RXbyte2 result and place in incomingByte 2
//Serial.println("Byte2");
//Serial.println(incomingByte2);
SPI.transfer(0b00000011); // Send Third byte
delay(1);
//incomingByte3 = SPI.transfer(0); // get RXbyte3 result and place in incomingByte 3
//Serial.println("Byte3");
//Serial.println(incomingByte3);
SPI.transfer(0b11000000); // Send Forth byte
delay(1);
//incomingByte4 = SPI.transfer(0); // get RXbyte4 result and place in incomingByte 4
//Serial.println("Byte4");
//Serial.println(incomingByte4);
SPI.transfer(0b00000000); // Send Fifth byte
delay(1);
//incomingByte5 = SPI.transfer(0); // get RXbyte5 result and place in incomingByte 5
//Serial.println("Byte5");
//Serial.println(incomingByte5);
SPI.transfer(0b00000000); // Send Sixte byte
delay(1);
//incomingByte6 = SPI.transfer(0); // get RXbyte6 result and place in incomingByte 6
//Serial.println("Byte6");
//Serial.println(incomingByte6);
delay(1);
//Set CS_Pin High
digitalWrite(CS_Pin, HIGH); // Enable internal pull-up
//Set SerialPrint 6 Bytes
//Serial.println("Byte1");
//Serial.println(incomingByte1);
//Serial.println("Byte2");
//Serial.println(incomingByte2);
//Serial.println("Byte3");
//Serial.println(incomingByte3);
//Serial.println("Byte4");
//Serial.println(incomingByte4);
//Serial.println("Byte5");
//Serial.println(incomingByte5);
//Serial.println("Byte6");
//Serial.println(incomingByte6);
delay(10000); // 100ms Wait
}