CODE WOOP WOOP

Hello, i am a beginner in Arduino programming. Can someone explain me how this part of the code works, it's very complicated for me and I want to understand how it works.

t would be great if someone could help me.

Thanks

I'm going to post the part of the code

void woopWoop() {
if (loading) {
clearCube();
cubeSize = 2;
cubeExpanding = true;
loading = false;
}

timer++;
if (timer > WOOP_WOOP_TIME) {
timer = 0;
if (cubeExpanding) {
cubeSize += 2;
if (cubeSize == 8) {
cubeExpanding = false;
}
} else {
cubeSize -= 2;
if (cubeSize == 2) {
cubeExpanding = true;
}
}
clearCube();
drawCube(4 - cubeSize / 2, 4 - cubeSize / 2, 4 - cubeSize / 2, cubeSize);
}
}

fabiancaptari:
Hello, i am a beginner in Arduino programming. Can someone explain me how this part of the code works, it's very complicated for me and I want to understand how it works. I would be great if someone could help me.

Thanks

fabiancaptari,
first off, you should post or point to the specific code you are questioning.

billz1:
fabiancaptari,
first off, you should post or point to the specific code you are questioning.

I'm sorry, now i modified the the message. I wanted to post the part of the code and unintentionally I posted it without the code

OK, but just needs some tidying up. :grinning:

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you later need to post that) from the IDE and click the icon.

In fact, the IDE itself has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. While you were lucky so far, If you do not post it as "code" it can as you may notice, be slightly garbled and is generally more difficult to read due to the font.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

Why do we think this is more important than just having your question answered? Because it is really difficult to write code properly - as with any other task requiring care - if everything is not well organised!

fabiancaptari:
Hello, i am a beginner in Arduino programming. Can someone explain me how this part of the code works, it's very complicated for me and I want to understand how it works.

From what you posted, this code will do nothing. See, the void woopWoop routine is never called here. May be called in the other portion of the program that you did NOT post. Also WOOP_WOOP_TIME or cubeSize are not set to any value. Timer is not ever chanted from zero.
For us to help, you must post or point us to all of the code.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.