Blinking an LED
This program will turn an LED connected to pin 14 on for one second, and then off for one second, and will repeat the cycle indefinitely.
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:
void setup()
{
pinMode(14, OUTPUT); // sets pin 14 as output
}
void loop()
{
digitalWrite(14, HIGH); // turns the LED on pin 14 on
delay(1000); // waits for one second
digitalWrite(14, LOW); // turns the LED on pin 14 on
delay(1000); // waits for one second
}
Remember that in the PBASIC program, everything typed after each apostrophe, and in the Arduino program everything typed after the two forward slashes is a comment that has no effect on the program execution.
Comments (0)
You don't have permission to comment on this page.