C++ I/O with Propeller and SimpleIDE
dirtrider444
Posts: 33
Hello
I am trying to understand how to get my propeller board to do "Hello World" or (get an led to blink) with SimpleIDE. I found this code below on this forum but when I compile, it says the output is not declared along with the high and low definitions. I just finished my C++ class(we didnt do anything with a microcontroller) so this is fairly new to me. Any help would be appreciated!
Taylor
/* Blinking LED
*
*
* turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 2 seconds.
*
* Created 1 June 2005
* copyleft 2005 DojoDave <http://www.0j0.org>
*
* based on an orginal by H. Barragan for the Wiring i/o board
*/
#include <iostream>
#include <cstdlib> // function generator for random number
#include <ctime> // starts system clock
using namespace std;
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
I am trying to understand how to get my propeller board to do "Hello World" or (get an led to blink) with SimpleIDE. I found this code below on this forum but when I compile, it says the output is not declared along with the high and low definitions. I just finished my C++ class(we didnt do anything with a microcontroller) so this is fairly new to me. Any help would be appreciated!
Taylor
/* Blinking LED
*
*
* turns on and off a light emitting diode(LED) connected to a digital
* pin, in intervals of 2 seconds.
*
* Created 1 June 2005
* copyleft 2005 DojoDave <http://www.0j0.org>
*
* based on an orginal by H. Barragan for the Wiring i/o board
*/
#include <iostream>
#include <cstdlib> // function generator for random number
#include <ctime> // starts system clock
using namespace std;
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(1000); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(1000); // waits for a second
}
Comments
You don't have any libraries to provide Arduino like functions (pinMode, digitalWrite, setup, loop, etc.) to your C++ program.
Which Propeller board are you using?
Have you looked at any of the tutorials on the PRopGCC wiki?
The LED toggle demo from teh PropGCC demos looks like this:
It does compile as a C++ program under PropGCC. I didn;t have a board handy to test it but there's no reason it shouldn't work if you have some LEDs properly connected to any pins on any propeller board.
Thanks,
Taylor
Arduino code is C++ hidden behind some functions and libraries which are specific to the Arduino environment.
If you are familiar with Arduino, there is Pellerduino which is an ongoing project to get the Propeller working under the Arduino IDE. If you aren't and generally in the long run, you're best off just learning how to use C++ and the Propeller libraries to start writing C++ code for the Propeller.
There are a few scattered examples and demos of C++ code with the PropGCC package. There are also a few folks around the forums that are actively coding C++ using PropGCC and SimpleIDE. Hopefully, they'll chime in with some advice sometime soon.
Good luck and have fun!!
Feel free to ask questions, the folks around here are pretty darn friendly!