Jump to content


  • Content Count

  • Joined

  • Last visited

Reputation Activity

  1. Like
    CodilX reacted to larsie in LEDs blink/fade with music?   
    If you just want a sound-level thing, only need a microphone board like this: https://www.sparkfun.com/products/9868 or http://www.seeedstudio.com/depot/grove-sound-sensor-p-752.html?cPath=25_27
    Connect the microphone board to an analog input of the MSP430 and use for example Energia to read the sound level. Go in a loop and read the sound level, then use the digital output of your MSP430s. Set more LEDs if the sound level is high. Then connect an LED (and a series resistor to ground) to each digital output. If you have large LEDs and want  lots of light, you need transistors or other driving circuits to give more current to your LEDs. 
    If the above is what you're looking for, I can draw a diagram for you. 
    If you want an equalizer, you could use this: https://www.sparkfun.com/products/10468 (you need to connect it to a mike board). It's quite a cool chip, and it would give you a more advanced effect. But it's slightly more tricky to use. 
  2. Like
    CodilX reacted to SirPatrick in LED Display?   
    Driving a large number of LEDs with a small number of pins is a very common challenge with microcontrollers. Many different ways exist to do this so choosing which one you want to use is dependent on many different factors. Because of this I will link you to some very detailed discussions that will allow you to choose which avenue you would like to pursue.
    A great MAKE Magizine forum posting on the subject
    http://forums.makezine.com/comments.php ... ionID=5356
    The stackoverflow of electronics has some really good input as well
    http://electronics.stackexchange.com/qu ... n-my-micro
    EDIT After posting I remembered an awesome RGB LED table project that uses a launchpad and an array of LED drivers.
    http://e2e.ti.com/group/microcontroller ... 47779.aspx
    And their code is here
    This should give you a solid start.
    So find a method you like and start implementing it. Ask questions along the way and we can help you get started in no time.
  3. Like
    CodilX reacted to bobnova in Simple one-button combination lock   
    One of my first MSP430 projects here, this is a (very) simple one-button combination lock. At the moment it's just using the launchpad's single button and the two LEDs for lock status. You'd need to figure out what you were locking or unlocking and add code for that obviously.
    It's all delay based, so it assumes you aren't doing anything overly crucial other than minding the button, or at least that the other tasks (if any) can be put on hold while the button is being used.
    I'm sure there are "better" ways to do it, but this seems to work so far!

    int counter; byte wiggleRoom = 25; //the amount + or - of the exact correct push length to pass a lock level, measured in 10ms steps. byte lockLevel = 1; //Stores what button press the lock is on boolean open = false; boolean buttonState; int test1 = 100; //Number of 10ms steps the button should be held down for the first time int test2 = 50; //Same, for press two. int test3 = 100; //And press 3. So for this setup, we press for 1s, let up, press for 0.5s, let up, press for 1s void setup(){ pinMode(P1_0, OUTPUT); pinMode(P1_6, OUTPUT); pinMode(P1_3, INPUT_PULLUP); } void loop(){ if (!open){ // normal state, red LED on, green LED off. digitalWrite(P1_0, HIGH); //In this section you would shut the lock, whatever it was. digitalWrite(P1_6, LOW); } else{ digitalWrite(P1_6, HIGH); //Open the lock digitalWrite(P1_0, LOW); delay(3000); //Wait a bit. lockLevel = 1; open = false; //Set the lock to close next pass through the code. //Might not be a bad idea to close the lock here too, really. //That would prevent the button being held down keeping the lock open. } buttonState = digitalRead(P1_3); if (!buttonState){ //Button is pushed counter = 0; //reset the counter, this is crucial. while (!buttonState){ //As long as the button is held down, this cycles. counter++; delay(10); //10ms per cycle, record the number of cycles. buttonState = digitalRead(P1_3); //We do need to get out eventually, when the button opens } switch (lockLevel){ //Now that we have a press duration, we need to find what level the lock is on case 1: //If it's the first press, we start here. if (counter >= test1 - wiggleRoom && counter <=test1 + wiggleRoom){ lockLevel = 2; //Adjust wiggleRoom to be the number of 10ms steps you want for wiggle room. counter = 0; //Right now we get +/- 250ms. digitalWrite(P1_6, HIGH); //Flash the green LED if the push was successful. Mostly for debugging. delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over. counter = 0; } break; case 2: if (counter >= test2 - wiggleRoom && counter <=test2 + wiggleRoom){ //Second push, same deal. lockLevel = 3; counter = 0; digitalWrite(P1_6, HIGH); delay(50); digitalWrite(P1_6, LOW); } else{ lockLevel = 1; //If the push is the wrong length, start over from push 1. counter = 0; } break; case 3: if (counter >= test3 - wiggleRoom && counter <=test3 + wiggleRoom){ open = true; //Third correct push opens the lock. counter = 0; } else{ lockLevel = 1; counter = 0; } break; } } }
    The next thing I'm inclined to work on is some learning, so that it remembers how long you hold the buttons down and adjusts the official "correct" number to match over time. The other thought is to time the delay between presses and use that as part of the combination, it would complicate the code fairly significantly but also increase security for a given time spent with the button.
    I got the idea while contemplating vehicle security, my thought was to re-use a dash button as the input button and control the fuel pump relay (that wouldn't turn off after three seconds!). That would give you totally invisible anti-theft in theory.
    I can't recommend it exactly, depending on how it's wired a dead MSP430 may render the vehicle suddenly stopped, not ideal!
  4. Like
    CodilX reacted to energia in Serial communication somewhat broken?   
    The minimal libc that comes with mspgcc does not implement realloc. In the current release there is a bug in which realloc was erroneously replaced by malloc. I have put in a quick and dirty fix for this to work around this until libc gets realloc implemented. The patch is here: https://github.com/energia/Energia/comm ... 0c977c680f

    --- a/hardware/msp430/cores/msp430/WString.cpp +++ b/hardware/msp430/cores/msp430/WString.cpp @@ -140,6 +140,7 @@ unsigned char String::changeBuffer(unsigned int maxStrLen) char *newbuffer = (char *)malloc(maxStrLen + 1); if (newbuffer) { + strncpy(newbuffer, buffer, len); free(buffer); buffer = newbuffer; capacity = maxStrLen;
    In the file hardware/msp430/cores/msp430/WString.cpp around line 143 just under "if (newbuffer) {" add "strncpy(newbuffer, buffer, len);"
  5. Like
    CodilX reacted to energia in Internal temperature and state of LED?   
    Temperature offset error is not just a bit as I stated in the previous post. It can be significant as per MSP430x2xx user manual:
    Quickest way to calibrate would be to measure your room temperature with an accurate temperature measurement device or estimate it. Then let the LaunchPad sit there running the temp sense demo for a bit. At the end of that period take average value displayed in the serial console, subtract the actual room temperature and use that as the offset in the Sketch.
  6. Like
    CodilX reacted to olivluca in Serial communication somewhat broken?   
    It's not the serial that's broken but the String class that has some problems with reallocating memory:
  7. Like
    CodilX reacted to olivluca in Internal temperature and state of LED?   
  8. Like
    CodilX reacted to energia in Internal temperature and state of LED?   
    Floats should be avoided if possible. Since the MSP430 does not have a floating point unit it need to "emulate" one which makes it very slow. The "emulation" code is about 4k. Rei Vilo has put together an excellent example for how to read the temp sensor.
    https://github.com/energia/Energia/blob ... er_430.ino
    Bare in mind that the temp sensor is not calibrated and might be of a bit.
  • Create New...