Go Down

Topic: Problem with " for loop()" (resolved) (Read 864 times) previous topic - next topic

Cesar-S

Dec 07, 2011, 09:42 pm Last Edit: Dec 07, 2011, 10:48 pm by Cesar-S Reason: 1
Hello, I'm new to Arduino. I have the following problem with  for loop()

The LED does not stop, I need to know because it does not stop at ARDUINO, and if MINIBLOQ

Arduino ; print "0,1,2,3,4,0,1,2,3 ...." no stop led

Code: [Select]

int _i;

void setup()
{
Serial.begin(9600);
pinMode( 13 , OUTPUT);
}

void loop()
{
for (_i=0; _i< ( 5 ); ++_i )
{
digitalWrite( 13 , HIGH );
delay( 200 );
digitalWrite( 13 , LOW );
delay( 200 );
Serial.print( _i );
Serial.println("");
}

}


Arduino + Ardublock ; but does not stop printing

Code: [Select]

int _ABVAR_1_;

void setup()
{
Serial.begin(9600);
pinMode( 13 , OUTPUT);
}

void loop()
{
for (_ABVAR_1_=0; _ABVAR_1_< ( 5 ); ++_ABVAR_1_ )
{
digitalWrite( 13 , HIGH );
delay( 200 );
digitalWrite( 13 , LOW );
delay( 200 );
Serial.print( _ABVAR_1_ ); print  5,5,5,5,5......
Serial.println("");
}

}


Minibloq ; stops but does not print text

Code: [Select]

#include "stdlib.h"
#include "IRremote.h"
#include "pitches.h"
#include "Minibloq.h"


void setup()
{
initBoard();

for(unsigned int _i=0; _i<(unsigned int)(5); _i++)
{
DigitalWrite(D13_LED,
delay(100);
DigitalWrite(D13_LED,
delay(100);
}
}

void loop()
{
}


Modkit ; Modkit, stops, I have the Alpha account, I can not see the code and print text

Thanks

AWOL

#1
Dec 07, 2011, 09:45 pm Last Edit: Dec 07, 2011, 09:53 pm by AWOL Reason: 1
Your first problem is not with the for loop but with the function "loop ()", which....loops.

If you just want one cycle of the for loop, put it in setup() and leave loop() blank.

Second problem doesn't even compile (I didn't even try), so I don't know why you say it doesn't print anything.

Code: [Select]
DigitalWrite(D13_LED,
What's that?

Quote
Modkit ; Modkit, stops, I have the Alpha account, I can not see the code and print text

I can't even begin to guess what that means.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Cesar-S

What I need is to blink (x) amount and stop.
Minibloq works but I can not put Serial.print texts
In MINIBLOQ I must be wrong
I will try from Arduino, your suggestion

Thanks

PD: DigitalWrite(D13_LED) is a compilation with minibloq http://blog.minibloq.org/

Cesar-S

#3
Dec 07, 2011, 09:56 pm Last Edit: Dec 07, 2011, 09:59 pm by Cesar-S Reason: 1

Your first problem is not with the for loop but with the function "loop ()", which....loops.

If you just want one cycle of the for loop, put it in setup() and leave loop() blank.

Second problem doesn't even compile (I didn't even try), so I don't know why you say it doesn't print anything.

Code: [Select]
DigitalWrite(D13_LED,
What's that?

Quote
Modkit ; Modkit, stops, I have the Alpha account, I can not see the code and print text

I can't even begin to guess what that means.


http://www.modk.it/editor/preview/ http://blog.minibloq.org/ http://blog.ardublock.com/

I'm trying, I would like to do with Arduino MAIN but I get no  :D

Thanks

AWOL

Quote
I'm trying, I would like to do with Arduino MAIN but I get no 

I'm sorry, I don't know what you mean by "Arduino MAIN ".

I've never used a graphical environment for the Arduino - does it have its own forum?

I'm guessing that English is not your native language - is there someone who can help you in the International section?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Cesar-S

#5
Dec 07, 2011, 10:46 pm Last Edit: Dec 07, 2011, 10:48 pm by Cesar-S Reason: 1
Thanks, solved  XD  with  ARDUINO 1.0 .

Code: [Select]


int pinLED = 13;

void setup()
{
       {
        Serial.begin(9600);
        pinMode( 13 , OUTPUT);
        }
for(unsigned int _i=0; _i<(unsigned int)(10); _i++)
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
       Serial.println(_i);
}
}

void loop()
{
}

AWOL

#6
Dec 07, 2011, 10:58 pm Last Edit: Dec 07, 2011, 11:20 pm by AWOL Reason: 1
Code: [Select]

const int pinLED = 13;

void setup()
{
 Serial.begin(9600);
 pinMode( pinLED, OUTPUT);

 for(int i=0; i < 10; i++) {
   digitalWrite(pinLED, HIGH);
   delay(1000);
   digitalWrite(pinLED, LOW);
   delay(1000);
   Serial.println(i);
 }
}

void loop()
{
}
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


juliandasilva

I only want to add this that it's possible to print in Minibloq with the Serial block. But in the current version, it will only print numbers, not text. That may be enough for this example, but will not be able to print the automatic generated variable for the repeat block (called "_i") so you will need to add a second variable as counter to print it.

Regarding the question about the Minibloq forum, it's here:

minibloq.net/forum

Cheers,
Julián

terryking228

Hi, If you're interested in following the development of ArduBlock, mentioned above, there is now a discussion group here:
http://groups.google.com/group/ardublock?hl=en
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Go Up