basic stamp language to arduino language

do anyone have any idea how to convert the basic stamp code to arduino code because i have one and i want to convert it plz help.

' Test X Band Motion Detector.bs2
' Test to see the number of cycles the X Band Motion Detector
' sends in respons to motion.

' {$STAMP BS2} ' Module = BASIC Stamp 2
' {$PBASIC 2.5} ' Language = PBASIC 2.5

XbandEnPin PIN 9 ' Enable pin
XbandOutPin PIN 8 ' Output pin

HalfSecond CON 500 ' ms in 1/2 s delay
MoveThreshld CON 2 ' Motion threhold

cycles VAR Word ' Cycle counter
reps VAR Word ' Test repetitions

HIGH XbandEnPin ' Enable motion detector

FOR reps = 1 TO 360 ' Check for 3 minutes

COUNT XbandOutPin, HalfSecond, cycles ' Count OUT pin transitions

DEBUG HOME, "cycles = ", ' Display cycle count
DEC cycles, CLREOL

IF cycles > MoveThreshld THEN ' Display motion/no motion
DEBUG CR, "Motion detected!"
ELSE
DEBUG CR, "No motion", CLREOL
ENDIF

NEXT ' Repeat detection loop

LOW XbandEnPin ' Disable motion detector

DEBUG CR, "Test done, motion detector disabled." ' Display all done.

STOP ' Stop the program holding EN
' low

Has nobody told you to read the how to use the forum sticky post and to post your code using correct code tags.

Basic and C are not too dissimilar but there is no one to one conversion you can learn. You have to look at the code, look what it is doing and write the new code in C.

When in Rome.....

Something pretty much like:

// XbandEnPin     PIN     9                     ' Enable pin
static const int XbandEnPin = 9;
// XbandOutPin    PIN     8                     ' Output pin
static const int XbandOutPin = 8;
// HalfSecond     CON     500                   ' ms in 1/2 s delay
static const int HalfSecond = 500;
// MoveThreshld   CON     2                     ' Motion threhold
static const int CON = 2;

// cycles         VAR     Word                  ' Cycle counter
// reps           VAR     Word                  ' Test repetitions
int cycles, reps;

void setup() {
// HIGH XbandEnPin                              ' Enable motion detector
  digitalWrite(XbandEnPin, High);
// FOR reps = 1 TO 360                          ' Check for 3 minutes
  for (int reps = 1; reps <= 360; reps++) {
//   COUNT XbandOutPin, HalfSecond, cycles      ' Count OUT pin transitions
//
//  Arduino has no direct equivalent of COUNT, as far as I know.  You'll have
//  to write it using more primitive primitives like digitalRead()

//   DEBUG HOME, "cycles = ",                   ' Display cycle count
    Serial.print(" "cycles = ");
//         DEC cycles, CLREOL
    Serial.println(cycles);
(note: neither Arduino nor its serial monitor support HOME, CLREOL, etc.
//   IF cycles > MoveThreshld THEN              ' Display motion/no motion
//     DEBUG CR, "Motion detected!"
    if (cycles > MoveThreshld) {
      Serial.println("Motion detected!");
    }
//   ELSE
//     DEBUG CR, "No motion", CLREOL
    else {
      Serial.println("No motion");
//   ENDIF
    }
// 
// NEXT                                         ' Repeat detection loop
  }
// LOW XbandEnPin                               ' Disable motion detector
  DigitalWrite(XbandEnPin, Low);
// DEBUG CR, "Test done, motion detector disabled."  ' Display all done.
  Serial.println("Test done, motion detector disabled.");
// STOP                                         ' Stop the program holding EN
// (Arduino code will "stop" by running loop() continuously, doing nothing.
}

void loop() {}

@westfw, it would be a good idea if your example could be saved somewhere for future reference.

(You must have more time on your hands than I have:))

...R

BASIC Stamps and Picaxe are similar in syntax...
I did a few comparisons of example code as while back showing both BASIC and Arduino...

Ray

Grumpy_Mike:
Has nobody told you to read the how to use the forum sticky post and to post your code using correct code tags.

That's crazy talk.

Ain't nobody got time for that...

mental note: Next time someone asks for a graduation project we should think of a STAMP BASIC interpreter ..

mental note:

Are you sure you wish to risk such an earth-shacking production to your memory?
XD
Better to write it down in ink!

Ray