Need some Advice with LCD / LED / Repetitions
hi everyone,
i'm trying repetition counter weight training.
in scenario, green light reward reaching 10 reps.
the red light pause minute before start counting new set of reps again (from 0) , resetting loop.
i'm doing step counter , lcd display screen.
so far i've written following code - i'm stuck, reps keep increasing , won't stop @ 10 , reset 0.
thanks help.
the code:
#include <liquidcrystal.h>
liquidcrystal lcd(12,11,5,4,3,2);
const int tiltsensor = 8;
int reps = 0;
int switchstate = high;
int prevswitchstate = low;
int repsmax = 10;
void setup() {
lcd.begin(16,2); // type of lcd(16 columns , 2 rows)
pinmode(10,output);// red led
pinmode(9,output);//green led
pinmode(tiltsensor,input);
lcd.clear();
lcd.setcursor(0,0); // cursor on lcd characters placed
lcd.print("workout time"); // print characters on screen
lcd.setcursor(0,1);
lcd.print("lets go !");
}
void loop() {
switchstate = digitalread(tiltsensor);
if (switchstate != prevswitchstate) {
if (switchstate == low) {
reps = reps + 1;
lcd.clear();
lcd.setcursor(0,0);
lcd.print("reps:");
lcd.setcursor(0,1);
lcd.print(reps/10);
}
prevswitchstate = switchstate;
if (repsmax<10);{
digitalwrite(9,low);
digitalwrite(10,low);
}
if (repsmax=10) ;{
lcd.clear();
digitalwrite(9,high);
digitalwrite(8,high);
}
}
}
i'm trying repetition counter weight training.
in scenario, green light reward reaching 10 reps.
the red light pause minute before start counting new set of reps again (from 0) , resetting loop.
i'm doing step counter , lcd display screen.
so far i've written following code - i'm stuck, reps keep increasing , won't stop @ 10 , reset 0.
thanks help.
the code:
#include <liquidcrystal.h>
liquidcrystal lcd(12,11,5,4,3,2);
const int tiltsensor = 8;
int reps = 0;
int switchstate = high;
int prevswitchstate = low;
int repsmax = 10;
void setup() {
lcd.begin(16,2); // type of lcd(16 columns , 2 rows)
pinmode(10,output);// red led
pinmode(9,output);//green led
pinmode(tiltsensor,input);
lcd.clear();
lcd.setcursor(0,0); // cursor on lcd characters placed
lcd.print("workout time"); // print characters on screen
lcd.setcursor(0,1);
lcd.print("lets go !");
}
void loop() {
switchstate = digitalread(tiltsensor);
if (switchstate != prevswitchstate) {
if (switchstate == low) {
reps = reps + 1;
lcd.clear();
lcd.setcursor(0,0);
lcd.print("reps:");
lcd.setcursor(0,1);
lcd.print(reps/10);
}
prevswitchstate = switchstate;
if (repsmax<10);{
digitalwrite(9,low);
digitalwrite(10,low);
}
if (repsmax=10) ;{
lcd.clear();
digitalwrite(9,high);
digitalwrite(8,high);
}
}
}
code: [select]
if (repsmax<10);
if (repsmax=10) ;
see semi-colons @ end of if statements? rid of them. happens? , comparison operator == not = (assignment). should handle reps > 10 somehow, cover eventualities.
Arduino Forum > Using Arduino > Project Guidance > Need some Advice with LCD / LED / Repetitions
arduino
Comments
Post a Comment