pine 140 Posted August 20, 2012 Share Posted August 20, 2012 Hi! I am trying the following code in Energia int firstSensor = 0; // first analog sensor int secondSensor = 0; // second analog sensor int thirdSensor = 0; // digital sensor int inByte = 0; // incoming serial byte void setup() { // start serial port at 9600 bps: Serial.begin(9600); pinMode(2, INPUT); // digital sensor is on digital pin 2 establishContact(); // send a byte to establish contact until receiver responds } void loop() { // if we get a valid byte, read analog ins: if (Serial.available() > 0) { // get incoming byte: inByte = Serial.read(); // read first analog input, divide by 4 to make the range 0-255: firstSensor = analogRead(A0)/4; // delay 10ms to let the ADC recover: delay(10); // read second analog input, divide by 4 to make the range 0-255: secondSensor = analogRead(1)/4; // read switch, map it to 0 or 255L thirdSensor = map(digitalRead(2), 0, 1, 0, 255); // send sensor values: Serial.println(firstSensor, DEC); Serial.println(secondSensor, DEC); Serial.println(thirdSensor, DEC); } } void establishContact() { while (Serial.available() <= 0) { Serial.println('A'); // send a capital A delay(300); } } The terminal (hyperterm in Windows) is showing the expected "A" characters, but I am unable to type in any input. It looks like hyperterm just ignored anything typed in. Where could be the problem? Thanks in advance. Quote Link to post Share on other sites
energia 484 Posted August 20, 2012 Share Posted August 20, 2012 Hi pine, Which MSP430 do you have in the LaunchPad? I just now ran your code on a msp430g2553 and it works as expected. 1: On reset I see a continuous stream of 'A'. 2: On any key press connection is establised and I see the 3 analog values being printed. If you are running on a msp430g2231 then try changing the baudrate to 4800 with Serial.begin(4800); Robert pine 1 Quote Link to post Share on other sites
pine 140 Posted August 20, 2012 Author Share Posted August 20, 2012 Thanks Robert, i'm using a 2553. Thank for testing it out, it's good to know the code works and it helps to narrow down the search. Thanks again 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.