Menu

Arduino Code Issues

brownrb
2014-10-14
2015-11-30
<< < 1 2 (Page 2 of 2)
  • Rodney Mothersbaugh

    Robert,

    I am so sorry, i just got back from doing errands and realized that was the noobish thing i could have posted. Sorry and thanks.Here is the snippet that I changed.

    void setup() {
    // initialize Serial1 for ASCOM
    Serial1.begin(9600);

    analogWrite( Buzzer, 1023 );
    // turn ON both LEDS as power on cycle indicator
    analogWrite( bledIN, 1023 );
    analogWrite( gledOUT, 1023 );

    while(!Serial1); //ADDED BY RM


    void loop() {
    // process the command string when a hash arrives:

    CheckSerialPort(); //ADDED BY RM


    // Serial1Event occurs whenever new data comes in the Serial1 RX.
    //void Serial1Event() {
    // : starts the command, # ends the command, do not store these in the command buffer
    // read the command until the terminating # character
    //while (Serial1.available() && !eoc) {
    //inChar = Serial1.read();
    //if (inChar != '#' && inChar != ':') {
    //line[idx++] = inChar;
    //if (idx >= MAXCOMMAND) {
    // idx = MAXCOMMAND - 1;
    // }
    // }
    //else {
    //if (inChar == '#') {
    //analogWrite( gledOUT, 0 );
    //eoc = 1;
    //idx = 0;
    // }
    // }
    // }
    //}
    void CheckSerialPort() {
    while (Serial1.available() && !eoc) {
    inChar = Serial1.read();
    if (inChar != '#' && inChar != ':') {
    line[idx++] = inChar;
    if (idx >= MAXCOMMAND) {
    idx = MAXCOMMAND - 1;
    }
    }
    else {
    if (inChar == '#') {
    //analogWrite( gledOUT, 0 );
    eoc = 1;
    idx = 0;
    }
    }
    }
    }

     
  • brownrb

    brownrb - 2015-11-30

    Concerning the Micro

    "I am using a Arduino micro instead of a nano and it seems that with the micro the Serialevent function is not working. This means Ascom can't get a connection to the arduino"

    After some searching I found out that putting the function:

    void serialEventRun(void) {
    if (Serial.available()) serialEvent();
    }

    just before void setup() enables the serial communication.

    Maybe fixed in next release of IDE.

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.