Pages: [1]   Go Down
Author Topic: quick question: Ways to call functions from mai loop  (Read 489 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't find this in the reference section, or I'm just to green to know what to look for. I want to call an object (function from the main loop)
something like:
Code:
if viewState == 1 {call function mainView()}

mainView is not supposed to return any values, but simply print text and values to the LCD.
should i use a void for this?

Logged

0
Offline Offline
Faraday Member
**
Karma: 13
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void mainView(void) {
  // do whatever
}

void loop(void) {
 
  ....

  if (viewState == 1) {
    mainView();
  }

  ....
}

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks.  smiley
Logged

Pages: [1]   Go Up
Jump to: