Just joined. Found alot of the commands are the same as Basic. This is my work

LET P=10
DIM X(P),Y(P),A(P),B(P),M(P),F(P)
GC=.0001
DIM MASS(P)
FOR N=1 TO P
LET MASS(N)=.1
NEXT N
LET XL =2000
LET YL=1000
FOR N=1 TO P
LET X(N)=500+(RND(800))
LET Y(N)=250+(RND(500))
LET A(N)=(-.5+(RND(1)))
LET B(N)=(-.5+(RND(1)))
LET F(N)=1
LETM(N)=.01
LETX(N)=1000
LETY(N)=500+(N*20)
LET A(N)=.1+(N/10)
LETB(N)=0
NEXT N
LET X(1)=1000
LET Y(1)=500
LET MASS(1)=10
LET A(1)=0
LET B(1)=0
GOTO 80

LETX(2)=1000
LETY(2)=900
LET MASS(2)=1
LETA(2)=.5
LETB(2)=0
LETX(3)=1000
LETY(3)=800
LET MASS(3)=.1
LETA(3)=.6
LETB(3)=0
80 FOR N=1 TO P
IF F(N)=0 THEN GOTO 130
FOR M=1 TO P
IF N=M THEN GOTO 100
IF F(N)=0 OR F(M)=0 THEN GOTO 100
LET XD=X(M)-X(N)
LET YD=Y(M)-Y(N)
LET C=(XDXD)+(YDYD)
LET D=SQR C
LET F=(GC*((MASS(N)MASS(M))/D))
LET A(N)=A(N)+((F
(XD))/MASS(N))
LET B(N)=B(N)+((F*(YD))/MASS(N))
100
101 NEXT M
102
GCOL 0,15
CIRCLEFILL X(N),Y(N),(15+(MASS(N)))
105 LET X(N)=X(N)+A(N)
LET Y(N)=Y(N)+B(N)

FOR O=2 TO P
IF N=O THEN GOTO 110
IF INTX(N)=INTX(O) AND INTY(N)=INTY(O) THEN LET F(O)=0 : SOUND1,-15,100,10: LET MASS(N)=(MASS(N)+MASS(O)): REM LETA(N)=A(N)+(A(O)(MASS(O)/MASS(N))): LET B(N)=B(N)+(B(O)(MASS(O)/MASS(N)))
110 NEXT O
120
GCOL 0,0
CIRCLEFILL X(N),Y(N),((MASS(N))+10)
130 NEXT N
REM WAIT 1

LET E=-1000+X(1)
LET R=-500+Y(1)
FOR N=1 TO P
LET X(N)=X(N)-E
LET Y(N)=Y(N)-R
NEXT N
GOTO 80

Welcome to Arduno land.

Better look at mastering the examples which come with th IDE.

Check this out:

.

Hi,
And can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom… :slight_smile:

Some planets orbiting the sun in 2D.

I had forgotten why everyone disliked the original Basic so much. Thank you for reminding me.

Write your program in C/C++ THEN come to the Forum for assistance if it does not work.

...R

int moisture_val;
void setup() {
Serial.begin(9600);
pinMode (13, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
digitalWrite (7, HIGH);
digitalWrite (8, HIGH);
digitalWrite (9, HIGH);
}
void loop() {
for(int x = 0; x < 3; x++){
moisture_val = analogRead(x);
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(1000);
if (moisture_val > 800){
digitalWrite (13, HIGH);
digitalWrite (7 + x, LOW);
delay(10000);
digitalWrite (7 + x, HIGH);
}else{
digitalWrite (13, LOW);
}
}
delay(5000);
}

Ok so now I am writing in C. I do prefer Basic but feel happy now I can use for n loops, if, and dim array. Got 4 servos coming for the robot :slight_smile: Thanks for the welcome.

Thanks for the welcome

But you chose to ignore the bit about posting your code didn't you.

Please read all of this, especially section 7

How to use this forum

Here is your code more properly formatted for readability using the auto format feature of the IDE (Ctrl T) and posted in code tags (</>). Note that each { and } get their own line.

int moisture_val;

void setup() 
{
    Serial.begin(9600);
    pinMode (13, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    digitalWrite (7, HIGH);
    digitalWrite (8, HIGH);
    digitalWrite (9, HIGH);
}

void loop() 
{
    for(int x = 0; x < 3; x++)
    {
        moisture_val = analogRead(x);
        Serial.print("moisture sensor reads ");
        Serial.println( moisture_val );
        delay(1000);
        if (moisture_val > 800)
        {
            digitalWrite (13, HIGH);
            digitalWrite (7 + x, LOW);
            delay(10000);
            digitalWrite (7 + x, HIGH);
        }
        else
        {
            digitalWrite (13, LOW);
        }
    }
    delay(5000);
}

Hi,
All those goto- commands without return bring back a lot of memories :sweat_smile: , but posted between code-tags would indeed be nicer.

Anyway, the arduino IDE isn’t the only IDE you can use to program an Arduino.

BASCOM from www.mcselec.com can be used as well.

It’s similar to Quick-basic, is quite efficient with programming space, allows you to configure micro controller settings easily and standard supports most AVR 8-bit micro controllers.

Compared to the Arduino IDE it has a lot less support though.