Go Back   Aquarium Advice - Aquarium Forum Community > General Aquarium Forums > DIY Projects
Click Here to Login

Join Aquarium Advice Today
Reply
 
Thread Tools Search this Thread Display Modes
Please support our sponsors and let them know you heard about them on AquariumAdvice.com
 
Old 03-15-2011, 12:49 PM   #21
Aquarium Advice FINatic
 
Jnam's Avatar
 
Join Date: Sep 2008
Location: Boise ID
Posts: 757
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.
__________________

__________________
~Jason

36 BowFront Reef
LED PoweredPlanted 3G Picotope (Build thread)
Jnam is offline   Reply With Quote
Old 03-15-2011, 01:06 PM   #22
Aquarium Advice FINatic
 
AdamHorton's Avatar
 
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 575
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
__________________

__________________
-Adam Horton-
AdamHorton is offline   Reply With Quote
Old 03-15-2011, 05:28 PM   #23
Aquarium Advice FINatic
 
Jnam's Avatar
 
Join Date: Sep 2008
Location: Boise ID
Posts: 757
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.
__________________
~Jason

36 BowFront Reef
LED PoweredPlanted 3G Picotope (Build thread)
Jnam is offline   Reply With Quote
Old 03-15-2011, 10:04 PM   #24
Aquarium Advice FINatic
 
AdamHorton's Avatar
 
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 575
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...
__________________
-Adam Horton-
AdamHorton is offline   Reply With Quote
Old 03-16-2011, 12:39 PM   #25
Aquarium Advice FINatic
 
Jnam's Avatar
 
Join Date: Sep 2008
Location: Boise ID
Posts: 757
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...
__________________
~Jason

36 BowFront Reef
LED PoweredPlanted 3G Picotope (Build thread)
Jnam is offline   Reply With Quote
Old 03-16-2011, 12:41 PM   #26
Aquarium Advice FINatic
 
Jnam's Avatar
 
Join Date: Sep 2008
Location: Boise ID
Posts: 757
Quote:
Originally Posted by AdamHorton View Post
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.
__________________
~Jason

36 BowFront Reef
LED PoweredPlanted 3G Picotope (Build thread)
Jnam is offline   Reply With Quote
Old 03-16-2011, 07:17 PM   #27
Aquarium Advice FINatic
 
AdamHorton's Avatar
 
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 575
For posterity, I'm going to post a link to the new orange LEDs I'm buying. I'm going to replace the other side as well, even though it didn't break.

Flexible LED Strips
__________________
-Adam Horton-
AdamHorton is offline   Reply With Quote
Old 03-20-2011, 12:02 AM   #28
Aquarium Advice FINatic
 
AdamHorton's Avatar
 
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 575
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.
__________________
-Adam Horton-
AdamHorton is offline   Reply With Quote
Old 03-23-2011, 12:21 PM   #29
Aquarium Advice FINatic
 
Jnam's Avatar
 
Join Date: Sep 2008
Location: Boise ID
Posts: 757
nice!
__________________

__________________
~Jason

36 BowFront Reef
LED PoweredPlanted 3G Picotope (Build thread)
Jnam is offline   Reply With Quote
Reply

Tags
diy, led, led lighting, light, lighting

Please support our sponsors and let them know you heard about them on AquariumAdvice.com

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIY Led 10 gallon build thread/alternative diy co2 thread krap101 DIY Projects 62 09-03-2012 07:29 AM
Diy led cabezon DIY Projects 8 01-20-2011 02:17 PM
DIY LED Light help lbannie DIY Projects 5 01-07-2011 09:10 AM
Diy Led? Seepu DIY Projects 4 01-22-2008 11:41 PM
My $10 30 led DIY night light Jme DIY Projects 7 03-03-2007 12:07 AM







» Photo Contest Winners








Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -4. The time now is 04:05 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.