My While Loop Halts my program. Any advice?


so im working on robot project uni.
currently working on facial expressions robot.
got nokia 5110 screen hooked arduino @ moment , trying add gimicky loading bar animation.
only issue being while loop im using create blocks of loading bar causing program halt/hang , have no idea why.
any advice/help awesomesauce.

heres code far
code: [select]


#include <spi.h>
#include <adafruit_gfx.h>
#include <adafruit_pcd8544.h>
 
// pin 7 - serial clock out (sclk)
// pin 6 - serial data out (din)
// pin 5 - data/command select (d/c)
// pin 4 - lcd chip select (cs)
// pin 3 - lcd reset (rst)
adafruit_pcd8544 display = adafruit_pcd8544(7, 6, 5, 4, 3);
 
#define logo16_glcd_height 16
#define logo16_glcd_width  16

int ctstartup = 9;
 
//##############################################################
//######################  setup void  ##########################
//##############################################################

void setup()  {
serial.begin(9600);
  
display.begin();

display.setcontrast(50); //sets display contrast (best viewing setting)
display.cleardisplay();
display.settextsize(1);
display.settextcolor(black);
display.setcursor(7,10); //set display cursor location initialise typing
display.println("initialising");
display.setcursor(24,20); //shift typing down 2 pixels x axis same y position (x,y)
display.println("robots");
display.display();
delay(2500);


[b]
// loading bar bit
[/b]

[i]
[b]
display.cleardisplay(); //display loading bar upon startup (little bit gimmicky cool :d)
  display.drawrect(0, 13, 84, 20, black);
  display.display();
  delay(200);
  display.drawrect(3, 15, 2, 16, black);
  display.display();
  delay(200);
  display.drawrect(5, 15, 2, 16, black);
  display.display();
  delay(100);
  display.drawrect(7, 15, 2, 16, black);
  display.display();
  delay(500);
  
  do
  {
     display.fillrect(ctstartup, 15, 4, 16, black);
    display.display();
    ctstartup = (ctstartup + 4);        
  }
  while (ctstartup < 45);
 
  delay(500);
  display.drawrect(45, 15, 2, 16, black);
  display.display();
  delay(200);
  display.drawrect(47, 15, 2, 16, black);
  display.display();
  delay(200);
  
 do
 {
    display.fillrect(ctstartup, 15, 4, 16, black);
    display.display();
    ctstartup = (ctstartup + 4);    // displays cool loading animation uppon startup
 }
 while (ctstartup < 80);
[/b]
[/i]

[b]  
// gets stuck here need go onto stuff below :)
[/b]

display.cleardisplay(); //battle robots text
display.settextsize(2); //sets larger text (may need change)
display.settextcolor(black);
display.setcursor (7,20); //may need change fit text!!
display.println("battle");
display.setcursor (24,20); //may need change!!!
display.println("robots");
display.setcursor (32,7);
display.println("initialised");
delay(1000);
}

void loop(){
}

dont worry guys, amigo has informed me forgot put display.display(); @ end of battle robot code -_- small mistake blind see


Arduino Forum > Using Arduino > Programming Questions > My While Loop Halts my program. Any advice?


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