C++ I/O with Propeller and SimpleIDE
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:
/* This shows an example for creating an LMM program and Makefile. It simply toggles the pins at 1Hz rate. Copyright (c) 2011 Parallax, Inc. MIT Licensed. +-------------------------------------------------------------------- ¦ TERMS OF USE: MIT License +-------------------------------------------------------------------- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-------------------------------------------------------------------- */ #include "propeller.h" // this is a bit more elaborate than required, but // it shows usage of a basic C++ class class pinset { private: // these variables are not accessible outside the class unsigned int mask; // which pins are in this set unsigned int freq; // the frequency at which to toggle them public: // here are the public variables and methods // the basic constructor pinset(unsigned int m, unsigned int f) { mask = m; freq = f; DIRA |= m; } // the run loop void run(void) { for(;;) { OUTA ^= mask; waitcnt(freq+CNT); } } }; int main(void) { // create a set of pins to toggle at 2Hz pinset allpins(0x3fffffff, CLKFREQ>>1); // now go and toggle them, forever allpins.run(); }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!