Pages: [1]   Go Down
Author Topic: modify setup() from a class  (Read 540 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Dont think like a computer, make it think like you
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm thinking about making a class that automates setting up & reading from buttons. Would it be possible to set my pinModes (which & how many pins) dynamically? Can I modify setup() from a class?

Gabe
Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you can use pinmode anywhere in your code... you dont need to modify setup to do that

or make a class that has a method that gets executed in setup() and you can make some last nanosecond changes to the code

massimo
Logged

Florida, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 146
meow!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think newcomers to Arduino will find it quite helpful and revealing to study the startup code in:

    lib/targets/arduino/wiring.c

For example, if you look at main(), you see a bunch of hardware initialization stuff, and at the very end you see:

    setup();
    
    for (;smiley-wink
        loop();

Then it becomes very apparent that there is nothing special about what you can do in setup() vs loop().
Logged

Pages: [1]   Go Up
Jump to: