LCD printing values with delay changes all other delays


hello! want able print values lcd delay, because when values changes fast, lcd screen starts glitch.

if put delay(1000) here, , under lcdprint(analogread(a#)/10); starts change tempo of sequencer well. there way put delay message in ()?

i hope understand problem! br henrik




/*void setup () {}
#include <liquidcrystal.h>
#include <spi.h>
liquidcrystal lcd(12, 11, 5, 4, 3, 2);
void loop() {
 

  int sensorvalue = analogread(a0);
  int sensorvalue2 = analogread(a1);
  int sensorvalue3 = analogread(a2);
  int sensorvalue4 = analogread(a3);
 




  lcd.begin(16, 2);
 
  lcd.setcursor(0, 0);
   
  lcd.print(analogread(a0)/10);

//if put delay(1000) here, , under lcdprint(analogread(a#)/10); starts change tempo of sequencer well.
 
  lcd.setcursor(4, 0);
 
  lcd.print(analogread(a1)/10);
 
  lcd.setcursor(8, 0);
 
  lcd.print(analogread(a2)/10);
 
  lcd.setcursor(12, 0);
 
  lcd.print(analogread(a3)/10);
 
 
 



 
  int melody [] = {sensorvalue, sensorvalue2, sensorvalue3, sensorvalue4};
  //int notedurations = langd;
 
  (int thisnote = 0; thisnote < 4; thisnote++) {
   
    tone(7, melody[thisnote], analogread(a4));
   
     
   
   
   
    delay(analogread(a4));
}

/*}

if put delay(1000) here, , under lcdprint(analogread(a#)/10); starts change tempo of sequencer well. there way put delay message in ()?
each delay() means:
- stop whole program execution @ once!
- nothing amount of time go by
- start on next action

if program made "delay()", program execution stops each time reaches "delay()" , nothing time.

if want program run in pseudo-multitasking, doing several things @ (nearly) same time, must avoid delay()!

for example if want play note time, use millis() timer stop note:
- start playing note, remember time when ("unsigned long starttime=millis()")
- while note played check "if (millis()-starttime> timetoplay) ..." stop note played.


Arduino Forum > Using Arduino > Programming Questions > LCD printing values with delay changes all other delays


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code