so Ive been through a couple of blink without delay tutorial and Im trying to adapt what Ive learnt from there to print an array of characters on an lcd screen every second
so what I was trying to attempt here is that it would count the seconds on the lcd, using the serial read it appears to print all 3 quotes together at the beginning of the sketch and then that's it
thanks mark, I get what your saying.
With it taking the lcd_time from the millis will show wether or not an interval of 1000 has passed
Ive implemented this and this is how it looks
what happens now is every second it prints all three quotes rather than working its way through the array
this an be seen in the serial monitor
I was basing the original idea for this on a bit of code that I wrote with a delay
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char* count[]={"1 second", "2 seconds", "3 seconds"};
const int sec = 3;
const int time[sec] = {1, 1, 1};
const int sec_length = 1000;
void setup()
{
lcd.begin(16, 2);
lcd.clear();
Serial.begin(9600);
}
void loop()
{
lcd.clear();
for (int i = 0; i < sec; i++)//array through the notes
{
lcd.setCursor(3,0);
lcd.print(count[i]);
delay(time[i] * sec_length);
}
}
this work perfectly, working its way through the array in second intervals
you were saying crossroads that there was any value for count
is was thinking the value input is in the char* count[] array
only thing is I would still like to put this into a for function so that I may add a break function
any ideas on why the for function wasn't working as intended?
not too sure on what your definition of function is I was under the impression that if, else, while, for and the likes were functions
for arrays I have used before using the for (whatever it is) as I have done in the original piece worked
as in the programme made its way through the array
if you take a look at the original code I posted up I want to be able to display an array of quotes "1 second" "2 seconds" "3 seconds" in second intervals using an array with for (int 1 = 0; i < sec; i++) but without using a delay instead using millis
I have already achieved this with a speaker playing at the same time
the idea is part of an overall larger project for a breathalyzer where readings from pressure sensor will taking in the mean time and if pressure drop or raises too high due to breath rate then the programme will break out of the array and ask for the test to be restarted
I have this done with the delay, only thing is once I add the actual sensor the reading start becoming "screwy" the reason Im suspecting for this is that the delays used are causing them to become scramble so im trying to set up the sketch without delays so that it might run smoother