Pages: [1]   Go Down
Author Topic: Problem with " for loop()" (resolved)  (Read 641 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
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:
#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
« Last Edit: December 07, 2011, 04:48:23 pm by Cesar-S » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24308
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
« Last Edit: December 07, 2011, 03:53:16 pm by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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/
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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  smiley-grin

Thanks
« Last Edit: December 07, 2011, 03:59:56 pm by Cesar-S » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24308
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, solved  smiley-lol  with  ARDUINO 1.0 .

Code:

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()
{
}
« Last Edit: December 07, 2011, 04:48:50 pm by Cesar-S » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24308
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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()
{
}
« Last Edit: December 07, 2011, 05:20:10 pm by AWOL » Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks  smiley-wink
Logged

Argentina
Offline Offline
Full Member
***
Karma: 0
Posts: 186
Sé feliz
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1752
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Pages: [1]   Go Up
Jump to: