Shop OBEX P1 Docs P2 Docs Learn Events
How to do in pbasic what works in C ???? — Parallax Forums

How to do in pbasic what works in C ????

ErikdSErikdS Posts: 37
edited 2010-05-12 14:43 in BASIC Stamp
Hi there,

I'm trying to convert a little program written in C to pbasic, so I can kick out a microcontroller I don't want and replace it with the BS2 all my other stuff works great with.
Can anybody help me out here?

The programm goes like this:

void setup()
{
Serial.begin(38400);
delay(1000);
Serial.println("F8D1D1");
delay(500);
Serial.println("Ctester");
delay(200);
}

void loop()
{
Serial.print("STest 1,2,3");
Serial.println("Test Test!");
}


I gave it a try but it doesn't work, so I guess I'moverlooking something....
cry.gif

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2010-05-12 12:47
    You might explain each line of your 'C' program (for the 'C'-illiterati.)
  • ErikdSErikdS Posts: 37
    edited 2010-05-12 12:56
    Well, if I could do that this tread wouldn't be here.... that's my problem.

    What I can figure out:

    38400 is the baud rate
    F8D1D1 is the frrequency at which a STENSAT radio transmitter is to transmit data
    tester would be a call sign
    delay = pause (though not necessarily in the same units)
    serial.print and serial.println would be SOMEW>HAT akin to 'serout'

    as for all the rest, it might be Sanscrit for all the sense it me to poor pityful me

    Erik
  • Mike GreenMike Green Posts: 23,101
    edited 2010-05-12 13:53
    This looks like Arduino code. You might download some manuals from the Arduino website to be able to understand this stuff.

    It looks like the serial.begin sets the Baud and, on the Stamp, this information is included in each SEROUT statement.

    serial.print is the equivalent to SEROUT and the quoted string is what gets SEROUTed.

    serial.println is the same as serial.print, but with a carriage return ($0D) added to the end of whatever's sent.

    The stuff in the "setup" function is once-only initialization stuff

    The stuff in the "loop" function is repeated continuously

    You're correct about the "delay" function. I think the delay units are the same as the Stamp's PAUSE units (milliseconds).
  • Shawn LoweShawn Lowe Posts: 635
    edited 2010-05-12 14:16
    void setup()
    {
    Serial.begin(38400);
    delay(1000);
    Serial.println("F8D1D1");
    delay(500);
    Serial.println("Ctester");
    delay(200);
    }

    void loop()
    {
    Serial.print("STest 1,2,3");
    Serial.println("Test Test!");
    }

    TX··· PIN·· 1
    baud CON 38400

    main:
    pause 1000
    serout TX,baud "F8D1D1", cr
    pause 500
    serout TX,baud "Ctester", cr
    pause 200

    Do
    serout TX, baud "STest 1,2,3"
    serout TX, baud "Test! Test!", CR
    Loop

    A little rough, consult the PBasic guide for the specifics on SEROUT.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
  • ErikdSErikdS Posts: 37
    edited 2010-05-12 14:43
    Thx Mike! I'll have a look at the Arduino site. I'll be back if that's not enough!

    TC!

    Erik
Sign In or Register to comment.