Jump to content

deptowicz

Members
  • Content Count

    3
  • Joined

  • Last visited

About deptowicz

  • Rank
    Noob Class

Profile Information

  • Gender
    Not Telling
  1. deptowicz

    Control LED Dimming

    Thanks simpleavr for the info on using terminal. I tried using unsigned and got the same result.
  2. deptowicz

    Control LED Dimming

    Hi, I'm pretty sure the comm is working because if I rewrite the code without the brightness settings, that is, if (incomingByte == 'H') { analogWrite(GREEN_LED, 255); } if (incomingByte == 'L') { analogWrite(GREEN_LED, 0); } the code acts exactly the way I want it. Sending 'H' switches the LED ON(255) while sending 'L' switches the LED OFF(0). It is only when I try to control the brightness values that it fails to respond. Out of curiosity, how do I use terminal to see that what I type echoes back?
  3. deptowicz

    Control LED Dimming

    Hello, I've just started learning the basics of launchpad programming thru the samples in energia. As an exercise, I'm trying to control the green LED intensity from the PC keyboard using code from the PhysicalPixel and Fade samples. I'm sending keyboard input via the Serial Monitor window of energia. The code successfully uploads to the msp430g2231 but I'm not getting the result I'm expecting. That is press 'H' and 'L' to increase and decrease the LED intensity. Here's the code: int brightness = 128; int incomingByte; // a variable to read incoming serial data into void setup() { Serial.begin(4800); // initialize serial communication: pinMode(GREEN_LED, OUTPUT); // initialize the LED pin as an output: } void loop() { if (Serial.available() > 0) { // see if there's incoming serial data: incomingByte = Serial.read(); // read the oldest byte in the serial buffer: if (incomingByte == 'H') { brightness = brightness + 5; if (brightness >= 255) { brightness = 255; } analogWrite(GREEN_LED, brightness); } if (incomingByte == 'L') { brightness = brightness - 5; if (brightness <= 0) { brightness = 0; } analogWrite(GREEN_LED, brightness); } } } The Communication>Dimmer sample also does not work for me. I'm under the impression that the cause of the problem is similar.
×