Hello everyone,
Im well aware that there are multiple topics on this but everyones project is different ![]()
Currently im using:
Arduino Uno R3
LCD Keypad Shield
DS1302
DS18B20
My goal is to have it cycle through the day with the LEDs. The catch is that I would like to be able to change when the LEDs reach certain brightnesses through the menu, change the time through the menu, and change from C to F through the menu as well. My main LCD screen is exactly how I want it with display of time, LED%, and Temp but the LED% doesn't display because I haven't gotten that to work. Im very new with arduinos and this is my first project (I know its a lot to take on.) Id love some guidance on this. I have everything working but the menu and the LCDs. What I have so far is a mix between code Ive written and pieced together from others. If you could please give me some guidance that would be very helpful. Id like it all to run from that 1 led as well because im going to use it as a PWM signal to control a band using a MOSFET.
Thank you so much.
#include <OneWireTempSensor.h>
#include <DS1302.h>
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal.h>
int DS18S20_Pin = A3; //Sets the Temp pin
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int LED = 3;
//Temperature chip i/o
OneWire ds(DS18S20_Pin);
int currentMenuItem = 0;
int lastState = 0;
DS1302 rtc(2, A2, A1);
void setup() {
 //Set the characters and column numbers.
 lcd.begin(16, 2);
 //Print default title.
 clearPrintTitle();
}
void loop() {
Â
 float temperature = getTemp();
 lcd.setCursor(0, 0);
 lcd.print(rtc.getTimeStr());
 lcd.setCursor(0, 1);
  lcd.print("Temp : ");
  lcd.print(temperature);
  lcd.print(" *C");
  lcd.setCursor(9, 0);
  lcd.print("LED=%");}
  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::crc8( 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[i] = 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;
return TemperatureSum;
 //Call the main menu.
 mainMenu();
}
void mainMenu() {
 //State = 0 every loop cycle.
 int state = 0;
 //Refresh the button pressed.
 int x = analogRead (0);
 //Set the Row 0, Col 0 position.
 lcd.setCursor(0,0);
 //Check analog values from LCD Keypad Shield
 if (x < 100) {
  //Right
 } else if (x < 200) {
 //Up
  state = 1;
 } else if (x < 400){
 //Down
  state = 2;
 } else if (x < 600){
  //Left
 } else if (x < 800){
  //Select
  state = 3;
 }
 //If we are out of bounds on th menu then reset it.
 if (currentMenuItem < 0 || currentMenuItem > 4) {
 currentMenuItem = 0;
 }
 //If we have changed Index, saves re-draws.
 if (state != lastState) {
   if (state == 1) {
    //If Up
     currentMenuItem = currentMenuItem - 1;
     displayMenu(currentMenuItem);
   } else if (state == 2) {
    //If Down
     currentMenuItem = currentMenuItem + 1;Â
     displayMenu(currentMenuItem);
   } else if (state == 3) {
    //If Selected
    selectMenu(currentMenuItem);
   }
   //Save the last State to compare.
   lastState = state;
 }
 //Small delay
 delay(5);
}
//Display Menu Option based on Index.
void displayMenu(int x) {
  switch (x) {
   case 1:
    clearPrintTitle();
    lcd.print ("-> Set Time");
    break;
   case 2:
    clearPrintTitle();
    lcd.print ("-> Set Date");
    break;
   case 3:
    clearPrintTitle();
    lcd.print ("-> Light Cycle");
    break;
   case 4:
    clearPrintTitle();
    lcd.print ("-> Current Temp");
    break;
  }
}
//Print a basic header on Row 1.
void clearPrintTitle() {
 lcd.clear();
 lcd.setCursor(0,1);
 lcd.print(" TEMP ");
 lcd.setCursor(0,1);
}
//Show the selection on Screen.
void selectMenu(int x) {
 switch (x) {
   case 1:
    clearPrintTitle();
    lcd.print ("Selected Opt 1");
    //Call the function that belongs to Option 1
    break;
   case 2:
    clearPrintTitle();
    lcd.print ("Selected Opt 2");
    //Call the function that belongs to Option 2
    break;
   case 3:
    clearPrintTitle();
    lcd.print ("Selected Opt 3");
    //Call the function that belongs to Option 3
    break;
   case 4:
    clearPrintTitle();
    lcd.print ("Selected Opt 4");
    //Call the function that belongs to Option 4
    break;
  }
}