Hi, My name is Bruno, and i have recently started a new project for my Photography Hobby.
It will be a simple slider controlled by an arduino for time-lapses, sure I could get one already made or a Kit but it will be less fun so i decide to build my own custom made slider.
After toying with steppers and allot of planning to see what function it will have, I finally started to put some code together.
For now I am just building an simple example that sets up a screen, reads three buttons and displays a value stored in a variable, later this example will be use as base for completing the rest.
My knowledge of programming is very basic and most self taught, so her i ask for help because I am having trouble displaying the value that i want.
So basically goes like this after the introduction, it should read the select button and store the number of times that it was pressed, then it will call different functions based on the number of times pressed.
right now it only registers one time the select button and then calls a function, in the function reads the up button and ads 1 or the down button a takes 1 then it should display the result
here is the main program
#include <LiquidCrystal.h>
#include <Button.h>
LiquidCrystal lcd(12,11,5,4,3,2);
Button Select=Button(8,BUTTON_PULLDOWN);
Button Up=Button(9,BUTTON_PULLDOWN);
Button Down=Button(10,BUTTON_PULLDOWN);
int posCursor=0;
int Exposure=0;
void setup (){
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(5,1);
lcd.print("TimeStepper");
lcd.setCursor(15,4);
lcd.print("V 1.0");
delay(2000);
lcd.clear();
}
void loop() {
Lcdscreen();
cursorPos();
switch(posCursor){
case 1:
if (posCursor=1){
lcd.setCursor(9,1);
lcd.blink();
lcd.setCursor(10,1);
exposureTime();
}
//case 2:
//if (posCursor=2){
// posCursor=0;
//}
//lcd.noBlink();
break;
}
}
and here is the function that reads up and down
int exposureTime(){
if(Up.isPressed()){ //reads up button
Exposure=Exposure++;
}
else
{
if(Down.isPressed()){//reads down button
Exposure=Exposure--;
}
}
// while(posCursor=1);
if(Exposure>=60){
Exposure=Exposure/60;
}
else
{
if(Exposure<0)
{
Exposure=0;}
}
lcd.setCursor(10,1);
lcd.print(Exposure);
}
the other functions seems to work and the screen stays like this
|Timelapse Type: |
|Exposure: | it should display the value after Exposure and it should change with up
| | or down
I could go with a menu but i could not figure it out how to do it and i want to preset all the values on the screen and then press start to make the stepper work.
I am almost sure that it is something simple but my knowledge is limited (i paint cars for a living) so i ask for your help.
thanks!