DIY LED lighting

The friendliest place on the web for anyone with an interest in aquariums or fish keeping!
If you have answers, please help by responding to the unanswered posts.
Clean. if only my code was as pretty =( It gets the job done but it takes up way more memory than it needs to. (my code that is). I may steal your update time. Maybe you could help my with some code? I am using a voltage divider to run 3 buttons up down and enter and i have room for a forth, back or escpae. For the life of me I can wrap my head around using them to navigate a menu on the lcd. I want to have 4 choices on the screen and be able to go up and down the menu items until i hit enter and then it takes me to that submenu. I can figure out how to go down a tree

ie
hit enter
meny screen comes up
4 choices
a
b
c
d

if i hit down i can go to a b c or d if i over shood it can go d c b a. when i have selected something it goes to that menus sub menu ie a1 or b1 and so forth... I tried asking in the arduino forums but people just send me to libraries and things on the playground for things i dont want.

Sorry to hijack.
 
If I understand what you're asking correctly, you could use a variable to denote where the cursor is. I'm not 100% clear on your interface so hopefully this will be enough to get you going:

Code:
void DrawCursor(int row) {
  //clear off old cursor
  lcd.setCursor(0, 0);
  lcd.print(" ");
  lcd.setCursor(0, 1);
  lcd.print(" ");
  lcd.setCursor(0, 2);
  lcd.print(" ");
  lcd.setCursor(0, 3);
  lcd.print(" ");

  //draw new cursor
  lcd.setCursor(0, row);
  lcd.print("*");
}


int cursor = 0;

//output menu options
lcd.setCursor(2, 0);
lcd.print("A");
lcd.setCursor(2, 1);
lcd.print("B");
lcd.setCursor(2, 2);
lcd.print("C");
lcd.setCursor(2, 3);
lcd.print("D");

do {
  if (UP button pressed) {
    cursor++;
    if (cursor > 3) {
      cursor = 3;
    }
  }

  if (DOWN button pressed) {
    cursor--;
    if (cursor < 0) {
      cursor = 0;
    }
  }

  DrawCursor(cursor);
} while (OK button not pressed);

//cursor will now hold the value of what they selected
 
see simple and exactly what I wanted.
and then something to the effect
if(ok button pressed)
}
go to sub menu for cursor number
}

thank you.
 
Actually you don't even need your if (ok button pressed). You can just check the value of cursor after that last do/while loop, like this:

Code:
if (cursor == 0) {
  //do stuff for first sub-menu option
} else if (cursor == 1) {
  //...
}
In other news, it turns out that the orange LEDs I bought, that said they were waterproof... well, they aren't waterproof. One of them is shorting out. Looks like I'll be shopping for more orange LEDs...
 
That is usually the case. I bought submerisble LEDs for my reef tank I wanted to use them to highlight some corals at night. Plugged them in they seemed to work fine for a day or two but then at night the stopped coming on and my corals all looked pissed. My alarm kicked in on my PH meter well it was the stray voltage from the submerisbles good thing it was low voltage and the transformer only suppled like 100mA. I have seen people use a vacuum sealer to water proof and still keep the clarity...
 
Actually you don't even need your if (ok button pressed). You can just check the value of cursor after that last do/while loop, like this:

Code:
if (cursor == 0) {
  //do stuff for first sub-menu option
} else if (cursor == 1) {
  //...
}
In other news, it turns out that the orange LEDs I bought, that said they were waterproof... well, they aren't waterproof. One of them is shorting out. Looks like I'll be shopping for more orange LEDs...

I thought of that last night while I was incorporating the coding you came up with. and instead of if and else if I just used switch case to clean it up a bit.
 
Well the LED strips came in today, a lot faster than expected. I replaced both sides with the new orange LED strips, and tested everything and it all looks great. I'll probably take some new pictures/video soon, but the tank is looking like it could be ready for fish in a week or so and so I'd rather wait for that, at least there will be something interesting to take a picture of.
 
Back
Top Bottom