pbasic2arduino

 

Naming Pins and Declaring Variables

Page history last edited by CTP 2 yrs ago

Example of naming I/O pins, using the Blinking an LED code.

 

PBASIC code:

 

'{$STAMP BS2}

'{$PBASIC 2.5}

 

DO                     'begins a program loop called a "DO LOOP"

HIGH 14            'turns the LED on pin 14 on

PAUSE 1000      'waits for one second

LOW 14            'turns the LED on pin 14 off

PAUSE 1000      'waits for one second

LOOP                 'goes back to DO and starts over

 

 

Arduino code:

 

int ledPin = 14;       // LED connected to digital pin 14

 

void setup()

{

pinMode(ledPin, OUTPUT);  // sets pin 14 as an output

}

 

void loop()

{

digitalWrite(ledPin, HIGH);     // turns the LED on pin 14 on

delay(1000);                          // waits for one second

digitalWrite(ledPin, LOW);     // turns the LED on pin 14 on

delay(1000);                         // waits for one second

}

 

 

 

 

 

Comments (0)

You don't have permission to comment on this page.