BinaryA 0 Posted August 20, 2017 Share Posted August 20, 2017 HI All Im havng a number of problems, Serial monitor doesn't seem to work for programs Ive written yet if I use an example sketch with serial prints in it the example sketch works. If I add a some simple button reading code to the example sketch the serial monitor stops working. I have a 10kOhm resistor connected to ground the other end to pin4 and the button and other end of the button to Vcc. Ive spent three frustrating days trying to get this working. I have version 1.5 of the MSP430 launchpad with a MSp430g2553. The jumpers are connected horizontally for Txd and Rxd. Im using Energia r17 (which seems to hang the computer randomly). Ive tried different baud rates 9600 and 115200. I thought reading a couple of buttons and checking them on the serial monitor would take an hour to do boy how wrong was I.The MSP is com5 on my computer (checked this with device monitor, Im running windows 10) which is what I selected in energia and Ive selected the proper board. Ive even put in a new MSP430g2553 chip. Ive tried the AnaloguInOutSerial program and serial monitor works. I then added code but commented out the analog stuff so the sketch looks like this but serial monitor stops working. See below: /* Analog input, analog output, serial output Reads an analog input pin, maps the result to a range from 0 to 255 and uses the result to set the pulsewidth modulation (PWM) of an output pin. Also prints the results to the serial monitor. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +3.3V and ground * LED connected from digital pin 9 to ground created 29 Dec. 2008 modified 30 Aug 2011 by Tom Igoe This example code is in the public domain. */ // These constants won't change. They're used to give names // to the pins used: //const int analogInPin = A0; // Analog input pin that the potentiometer is attached to //const int analogOutPin = 9; // Analog output pin that the LED is attached to //int sensorValue = 0; // value read from the pot //int outputValue = 0; // value output to the PWM (analog out) const int b1=4; void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(b1,OUTPUT); } void loop() { int but1; // read the analog in value: //sensorValue = analogRead(analogInPin); // map it to the range of the analog out: //outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: //analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: but1=digitalRead(b1); Serial.print("button1 = " ); Serial.println(but1); // wait 500 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(500); } Can anybody tell me whats wrong is it a jumper setting? my code? my computer? Now and again I get error=57 and no unused fet when trying to upload not all of the time but some of the time. Something as simple as reading a button shouldnt be this difficult. Any help would be appreciated. Andy Quote Link to post Share on other sites
energia 485 Posted August 20, 2017 Share Posted August 20, 2017 Please see the BoosterPack pinout here: http://energia.nu/pin-maps/guide_msp430g2launchpad/ PIN 4 is the TX of the Serial on the G2553. Hence your Serial stops working if you utilize this as a digital input. You have a small mistake in the Sketch. You set pin 4 as output yet you do a digitalRead() in loop. Set the pin to pinMode(x, INPUT) (replace x with a pin number) in setup(). Use a pin other than 3/4 e.g. 6. I would advice to set the input as INPUT_PULLUP e.g. pinMode(6, INPUT_PULLUP) to utilize the internal PULLUP resistor and remove the external PULLDOWN resistor. Robert Quote Link to post Share on other sites
BinaryA 0 Posted August 20, 2017 Author Share Posted August 20, 2017 Hi Robert Thank you for the help. I couldn't see the woods for trees. Ill make that change to digital inputs and use the pullup internal resistors. I really appreciate the help. Andy Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.