Jump to content


  • Content Count

  • Joined

  • Last visited

  1. Thanks everyone. Just to test whether the logic is working fine, I wrote this sample piece of code: void setup() { // put your setup code here, to run once: Serial.begin(4800); } void loop() { // put your main code here, to run repeatedly: char c = 'A'; for (int i = 7; i >= 0; --i) { Serial.println( (c & (1 << i)) ? '1' : '0' ); } Serial.print("\n"); delay(1000); } I noticed one interesting thing- I can only see "readable" output when the baud rate is set to 9600. With baud rate less than that, i.e., 4800 or 1200, I see some gibberish, non human readable characters. Can anyone help me why is this happening? I am asking because, due to the nature of my project, I may need to slow down a bit while transmitting or receiving data. Thank you in advance,
  2. Thank you very much! Thanks a lot! I really appreciate your support.
  3. Thank you very much. At first, I would apologize for my incomplete post. I did try some code to get out of this loop, those are commented. What I posted here is just to keep running for the same input. I was stuck on getting out of the loop part. I am gonna try your suggestion and let you know about the result. Thanks again... I really appreciate.
  4. What I am trying to do is, making a PIN switch between its states (HIGH and LOW) with a random interval. My experiment outline is: There are two inputs from user, 1 and 2. An user input of 1 makes the LED to blink (or PIN to switch between HIGH and LOW) with a random interval between (500 to 1000) ms. If the user input is 2, the random interval becomes (100 to 500) ms. The system is should always listening to the user input, and as soon as it gets a new input, it adjusts the random delay accordingly. For example, the user gives an input of 1. The MSP430 chip generates a random number between (500 to 1000) ms. Let's assume it's 569 ms. Then the LED will blink with an interval of 569 ms. During the entire process, the launchpad will wait for the user input from serial monitor. If there's no input, it keep continuing with the input of 1, i.e., in the second cycle, it again generates a random number between 500 to 1000, and blink the led with specified delay. During this process, if the user passes an input of 2, the program will generate an different delay, between (100 to 500) ms. This delay range will continue until user does not passes a new input. I've written some piece of code, of stuck at one place. I really cannot figure out how to switch between delays, based on user input. Right now, if I pass 1 as an input initially, it keep going with delays associated with 1. I know, it's very novice question, but I am really not good at programming. Any help will be appreciated. Here goes my piece of code: int incomingByte = 0; // for incoming serial data void setup() { Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode(2,OUTPUT); } void loop() { // send data only when you receive data: while (Serial.available() > 0) { // read the incoming byte: incomingByte = Serial.read(); Serial.print ("The incomingByte value is: "); Serial.println (incomingByte, DEC); while (incomingByte == '1'){ Serial.print ("Now disrupting in slow mode with delay: "); digitalWrite(2,HIGH); int randomDelay = random(500,1000); delay(randomDelay); digitalWrite(2,LOW); delay(randomDelay); Serial.println(randomDelay); /*incomingByte = Serial.read(); Serial.print("New incomingByte is: "); Serial.println(incomingByte); if (incomingByte == 10){ continue; } if (incomingByte == '2'){ break; }*/ } while(incomingByte == '2'){ Serial.print ("Now disrupting in fast mode with delay: "); digitalWrite(2,HIGH); int randomDelay = random(100,500); delay(randomDelay); digitalWrite(2,LOW); delay(randomDelay); Serial.println(randomDelay); /*incomingByte = Serial.read(); if (incomingByte == 10){ continue; } Serial.print("New incomingByte is: "); Serial.println(incomingByte); if (incomingByte == '1'){ break; }*/ } } }
  5. Hi there! I am not very much experienced in MSP430 platform. I am kind of stuck in a problem. Let me describe my project goal first. What I want to do is: 1) I will input a letter (suppose "K") via serial monitor to my MSP430G2553, 2) Upon receiving the letter, the launchpad will vary the voltage level a GPIO PIN (let's assume P1.4) based on the input, which is connected to an LED, 3) As the LED blinks based on the input bit pattern (K, ASCII value = 75, Binary equivalent = 01001011), one light dependent resistor will read this variation, which is connected to another Launchpad, and stores it a buffer 4) The launchpad will read this buffer value, and print it to serial monitor So, this is essentially a chat module between two launchpad, using serial monitor and some electronic stuff. My Problem: (I am using Energia for coding) I can read the character from Energia Serial Monitor, however, I don't know 1. How to transmit the received BIT pattern through a GPIO pin, towards a external LED. I am using the Hardware UART for communication with computer- Is there any other way, I can send data serially over regular GPIO PINs? Please let me know, if my question requires further clarification. I am working on it... if I can solve it, or have any update, I am gonna post it here. I'd really appreciate your help. Thank you in advance!
  • Create New...