Jump to content
Sign in to follow this  

help for newbie-arduino translation

Recommended Posts

Hi All

I have only a tiny shred of experience on the msp430. I have had some luck using Arduino platforms. So far all I have been able to do with the msp is to use it as an ultra low power timer. What I need to see is a translation of some simple arduino code into MSP format. I have scoured the code examples but cant find what I need, or cant understand it. Here is one such snippet. Thanks in advance for any help.


const int analogPin = A0; // pin that the sensor is attached to

const int ledPin = 13; // pin that the LED is attached to

const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input


void setup() {

// initialize the LED pin as an output:

pinMode(ledPin, OUTPUT);

// initialize serial communications:




void loop() {

// read the value of the potentiometer:

int analogValue = analogRead(analogPin);


// if the analog value is high enough, turn on the LED:

if (analogValue > threshold) {

digitalWrite(ledPin, HIGH);


else {




// print the analog value:

Serial.println(analogValue, DEC);



Share this post

Link to post
Share on other sites

You may want to look into the MSPhere libraries being developed by forum member gatesphere, with contributions from other forum members. There's a section of the forum dedicated to it off the main page.


Most of the arduino code you supplied can be translated close to line-for-line. The 'Serial.println()' and digitalWrite() calls though, are from libraries. MSPhere attempts to replicate these libraries, but there is always the code space limitation (all MSP430 value line but the new 20-pin chips have only 2K of code space). Because of this, you will see that most of the code here does not use libraries.


I tried adding the stdio library to my project, using only one of its functions, and went from 0.6K to 1.95K. Obviously unacceptable.


tldr: Try the MSPhere libraries and examine their code (maybe get a new 20-pin chip with 8K also! :D ) to get used to the MSP430, then move into coding without libraries.

Share this post

Link to post
Share on other sites

What Doc said :P


However, at this moment in time, being the maintainer of MSPhere I recommend that if you use them at all, you should really tear them apart and rewrite your program without them after you get it to work the first time. Oh, and for serial stuff, you might want to check out NJC's excellent serial code.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...