Jump to content

canibalimao

Members
  • Content Count

    59
  • Joined

  • Last visited


Reputation Activity

  1. Like
    canibalimao reacted to juani_c in Launchpad+Accelerometer+Processing=Snake game!!!   
    I made this little project and wanted to share it. The code is mostly from "Half Duplex Software UART on the LaunchPad" by NJC, I just added the ADC parts I needed. The Processing application send first a "X" and the LP answer with the value from one of the axes, then send a "Y" and you get the value from the other axis. After that the soft update the snake position and repeat the process. In order to start the game you have to click on the START button (pretty obvious), you lose if the snake touchs any of the sides, also the length and speed increase as you eat the little boxes.
    The codes are far from perfect and can be improved. I'm making a little video (that actually took me almost the same amount of time I spent programming) and I'll upload it in a while.
     
     
    EDIT:here is the video
    Launchpad-Snake.rar
  2. Like
    canibalimao reacted to RobG in Audio Spectrum Analyzer - Part Deux   
    Here's a small WS2812 strip driven by one channel, color changes depending on the volume.

     
    And this is a single channel 7x8 matrix driver
  3. Like
    canibalimao reacted to RobG in Audio Spectrum Analyzer - Part Deux   
  4. Like
    canibalimao reacted to Rei Vilo in Thermometer with Nokia 5110 and Nokia 7110 LCD on Energia   
    Does the main sketch includes:
    // Include application, user and local libraries #include "LCD_5110.h" #include "Thermometer_430.h" Anyway, please find the project with all the files.
     
    LCD_5110_thermometer.zip
     
    Dealing with library may seem difficult at first. This tutorial provides a good introduction. Also, all the libraries are listed here.
     
     
  5. Like
    canibalimao reacted to Rei Vilo in Thermometer with Nokia 5110 and Nokia 7110 LCD on Energia   
    You need the Terminal6.h file.
     
    Find the whole project attached. 
     

     
    It compiles fine on my MacBook.
     
    LCD_5110_thermometer.zip
  6. Like
    canibalimao got a reaction from cubeberg in MSP430G2*** + RTC PCF8563   
    I'm getting it. I just need a diode between the VCC pin on the MSP430 and the power supply and connect the VCC pin also to a positive pin of a coin cell battery and the negative of that battery to the GND pin.
     
    I gess this can be more easy than it seems. But still I'll still wait for some electronic-geek reply :mrgreen:
     
    Thank you very much once again @@cubeberg
  7. Like
    canibalimao got a reaction from energia in RGB mixing colors   
    Hi guys.
     
    I create a program that mix all the 3 basic colors of the RGB leds.
     
    It uses 3 buttons (one for RED, other for BLUE and the other is... yes, you're right, GREEN). If you press one single button it rises the brightness of the correspondent color and then it fades (the famous "heartbeat"). If you press two or three buttons it raises the mix between those colors and then fades it.
     
    It's a pretty simple program just to show to kids how the light combine colors.
     
    Here you have the code:
    const int redLED= 9; // assign red LED to Pin #9 (P2.1) const int greenLED= 10; // assign green LED to Pin #10 (P2.2) const int blueLED= 12; // assign blue LED to Pin #12 (P2.4) const int redButton = 5; // assign red button to Pin #5 (P1.3) const int greenButton = 8; // assign green button to Pin #8 (P2.0) const int blueButton = 11; // assign blue button to Pin #11 (P2.3) void setup() { pinMode(redLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(blueLED, OUTPUT); pinMode(redButton, INPUT_PULLUP); pinMode(greenButton, INPUT_PULLUP); pinMode(blueButton, INPUT_PULLUP); } void loop(){ int sensorRED = digitalRead(redButton); int sensorGREEN = digitalRead(greenButton); int sensorBLUE = digitalRead(blueButton); int r=0; int g=0; int b=0; analogWrite(redLED, 0); analogWrite(greenLED, 0); analogWrite(blueLED, 0); if (digitalRead(redButton) == LOW) { while(r<255){ analogWrite(redLED, r); delay(30); r=r+5; if (digitalRead(greenButton) == LOW){ while (r<255){ analogWrite(redLED, r); analogWrite(greenLED, g); delay(30); r=r+5; g=g+5; if (digitalRead(blueButton) == LOW){ while (r<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } if (digitalRead(blueButton) == LOW){ while (r<255){ analogWrite(redLED, r); analogWrite(blueLED, ; delay(30); r=r+5; b=b+5; if (digitalRead(greenButton) == LOW){ while (r<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } } while(r>0){ analogWrite(redLED, r); delay(30); r=r-5; } while(g>0){ analogWrite(greenLED, g); delay(30); g=g-5; } while(b>0){ analogWrite(blueLED, ; delay(30); b=b-5; } } if (digitalRead(greenButton) == LOW) { while(g<255){ analogWrite(greenLED, g); delay(30); g=g+5; if (digitalRead(blueButton) == LOW){ while (g<255){ analogWrite(blueLED, ; analogWrite(greenLED, g); delay(30); b=b+5; g=g+5; if (digitalRead(redButton) == LOW){ while (g<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } if (digitalRead(redButton) == LOW){ while (g<255){ analogWrite(redLED, r); analogWrite(greenLED, g); delay(30); r=r+5; g=g+5; if (digitalRead(blueButton) == LOW){ while (g<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } } while(g>0){ analogWrite(greenLED, g); delay(30); g=g-5; } while(b>0){ analogWrite(blueLED, ; delay(30); b=b-5; } while(r>0){ analogWrite(redLED, r); delay(30); r=r-5; } } if (digitalRead(blueButton) == LOW) { while(b<255){ analogWrite(blueLED, ; delay(30); b=b+5; if (digitalRead(redButton) == LOW){ while (b<255){ analogWrite(blueLED, ; analogWrite(redLED, r); delay(30); b=b+5; r=r+5; if (digitalRead(greenButton) == LOW){ while (b<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } if (digitalRead(greenButton) == LOW){ while (b<255){ analogWrite(blueLED, ; analogWrite(greenLED, g); delay(30); b=b+5; g=g+5; if (digitalRead(redButton) == LOW){ while (b<255){ analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); r=r+5; g=g+5; b=b+5; } } } } } while(b>0){ analogWrite(blueLED, ; delay(30); b=b-5; } while(r>0){ analogWrite(redLED, r); delay(30); r=r-5; } while(g>0){ analogWrite(greenLED, g); delay(30); g=g-5; } } } Be free to made all the changes you want (if anyone get a way to make the code lighter I'll be very greatfull ) and post those changes here please. All changes are welcome!
     
     
    Hope you guys like this!
  8. Like
    canibalimao reacted to igendel in Tilt-sensitive rolling ball display   
    No doubt. When I get some free time to play with the Launchpad, I'm gonna bug you all big time! ;-)
     
    Be careful with what you wish...
     
    ok, here goes, attaching the code.
     
     
    RollBall.zip
  9. Like
    canibalimao reacted to semicolo in RGB mixing colors   
    Yes there's room for improvement, what about using variables to hold color increments, something like
    // debounce inputs and leave time to press another button if (digitalRead(redButton) == LOW || digitalRead(blueButton) == LOW || digitalRead(greenButton) == LOW) delay(50); // rinc, ginc, binc hold the r,g and b increments if (digitalRead(redButton) == LOW) rinc=5; else rinc=0; if (digitalRead(blueButton) == LOW) binc=5; else binc=0; if (digitalRead(greenButton) == LOW) ginc=5; else ginc=0; // go up to 255 int i; for (int i=0; i<51; i++) { r=r+rinc; g=g+ginc; b=b+binc; analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); } // go back down to 0 for (int i=0; i<51; i++) { r=r-rinc; g=g-ginc; b=b-binc; analogWrite(redLED, r); analogWrite(greenLED, g); analogWrite(blueLED, ; delay(30); } Not tested, I hope I didn't screw up the loop counts :-)
  10. Like
    canibalimao reacted to L.R.A in RGB mixing colors   
    The first is manual. The second is automatic. It has both possibilitys
     
    if you want a 3 button i have a sugestion.
     
    use 2. 1 increasses, another one decreasses.
    The 3rd one cycles wich color your actualy controlling.
    You can add 1-3 leds to show wich collor is selected to control. Just use a digital pin for them. Or not. It also works without them
     
    This about the size of my manual board:
    http://lusorobotica.com/index.php?action=dlattach;topic=6087.0;attach=1973;image
  11. Like
    canibalimao reacted to roadrunner84 in RGB mixing colors   
    const int num_colors = 3; // the number of individual colors const int LED[num_colors] = {9, 10, 12}; // assign red, green, blue LEDs to pins P2.1, P2.2 and P2.4 respectively const int Button[num_colors] = {5, 8, 11}; // assign red, green, blue buttons to P1.3, P2.0 and P2.3 respectively void setup() { for(int i = 0; i < num_colors; ++i) { pinMode(LED[i], OUTPUT); pinMode(Button[i], INPUT_PULLUP); } } void loop(){ int buttonstates[num_colors]; int colors[num_colors] = {0}; // read all buttons for(int i = 0; i < num_colors; ++i) { buttonstates[i] = digitalRead(Button[i]); } // increment in 51 steps for (int c = 0; c <= 255/5; ++c) { for(int i = 0; i < num_colors; ++i) { if (buttonstates[i] == LOW) colors[i] += 5; analogWrite(LED[i], colors[i]); } delay(30); } // decrement in 51 steps for (int c = 0; c <= 255/5; ++c) { for(int i = 0; i < num_colors; ++i) { if (buttonstates[i] == LOW) colors[i] -= 5; analogWrite(LED[i], colors[i]); } delay(30); } } Since you're doing basically everything in threefold, you can replace a lot of things with for loops to do things three times.
    Note that colors[] is always either a common value or zero, in this case you could replace it with a single counter and instead check whether to write zero or that value depening on buttonvalues[].
    const int num_colors = 3; // the number of individual colors const int LED[num_colors] = {9, 10, 12}; // assign red, green, blue LEDs to pins P2.1, P2.2 and P2.4 respectively const int Button[num_colors] = {5, 8, 11}; // assign red, green, blue buttons to P1.3, P2.0 and P2.3 respectively void setup() { for(int i = 0; i < num_colors; ++i) { pinMode(LED[i], OUTPUT); pinMode(Button[i], INPUT_PULLUP); } } void loop(){ static int states[num_colors]; static int colors[num_colors] = {0}; // read all buttons and set the incrementer accordingly for(int i = 0; i < num_colors; ++i) { if (digitalRead(Button[i]) == LOW) states[i] = 5; if (states[i] == LOW) colors[i] += states[i]; if (colors[i] > 255) { states[i] = -5; colors[i] += states[i]; // add MINUS 5 to colors[i] } if (colors[i] < 0) { states[i] = 0; // stop fading colors[i] = 0; // turn LED off } analogWrite(LED[i], colors[i]); } delay(30); } This variant will fade the LEDs independently, so while an LED is fading out, pressing the button will switch it to fading in again.
    Pressing the green button when the red LED is at it's brightest will cross fade from red to green.
    A lot of other fancy things can be done too, I think this would be much more fun for kids to mix light.
    Also note that this solution will not monopolise the chip; every time after the delay(30) is done the control is given back to Energia. If you'd be able to manage to get Energia to execute the loop() only every 30 delay ticks (ms?) you could get rid of the delay() statement alltogether.
  12. Like
    canibalimao reacted to oPossum in Volt/Amp/Watt meter   
    This is a simple voltage and current meter that uses the TI INA219 chip. Voltage measurement range is 0 to 26 volts with 4 mV resolution and current measurement range is -4 to +4 amps with 1 mV resolution (when using a 0.01 ohm shunt). The specs are inferior to a pair of quality multimeters, but it is a fraction of the price and shows wattage in addition to voltage and current. The Nokia 5110 display is used so the firmware could be enhanced to do simple graphing. Sending the measurements to a computer could also be done.
     
    Using the INA219 makes for a very simple circuit.

     
    The normal display is three lines with voltage, amperage and wattage.

     
    Pressing the P1.3 switch will show the 6 registers in the INA219 in hex and signed decimal.

     
    The code is written in C++ and uses templates for the LCD, IIC and INA219. Software SPI and IIC is used for maximum portability.
    vam.zip
  13. Like
    canibalimao reacted to spirilis in Using analogWrite   
    Yes and yes. They all have at least 1 Timer_A peripheral (in TI lingo) so they should all have at least 2 pins that can be used with analogWrite ()
     
    Sent from my Galaxy Note II with Tapatalk
     
     
  14. Like
    canibalimao reacted to bluehash in The Terminal - 43oh OLED Booster Pack   
    It comes pre-soldered. You don't need to do any soldering.
×
×
  • Create New...