Announcement

Collapse
No announcement yet.

Arduino Due problems

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Arduino Due problems

    Hi I am a newbie to these displays and not an expert with the Arduino but I have spent ages trying to get a simple test project to run using a Due. I did manage to get this to work with a Uno but my project needs more I/O's and AD Output.
    I have no problem writing to items but can't read anything back at all.
    Please help I don't have much hair left.

    Code I'm trying modded or copied from example but some things won't compile

    Code:
    #include <genieArduino.h>
    
    Genie genie;
    
    #define RESETLINE 2;
    int ost;
    
    void setup() { // put your setup code here, to run once:
      Serial.begin(200000);
      genie.Begin(Serial);
    
      //genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events //Get the message "Not Declared in this Scope;
    
    
      pinMode(RESETLINE, OUTPUT);
      digitalWrite(RESETLINE, 1);
      delay(100);
      digitalWrite(RESETLINE, 0);
      delay(5000);
      genie.WriteContrast(7);
    }
    
    void loop() {
      // put your main code here, to run repeatedly;
      genie.DoEvents();
    
      //ost=41;
      genie.WriteObject (GENIE_OBJ_USER_LED, 0, 1);
      genie.WriteObject (GENIE_OBJ_COOL_GAUGE, 0, 10);
      //genie.ReadObject (GENIE_OBJ_SLIDER, 0);
      //genie.WriteObject (GENIE_OBJ_LED_DIGITS, 0, ost); This Worked
    
    
      void myGenieEventHandler(void);
    
      genieFrame Event;
      genie.DequeueEvent(&Event);
    
      int slider_val = 0;
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {
        { Event.reportObject.object == GENIE_OBJ_SLIDER; // If the Reported Message was from a Slider
    
          if (Event.reportObject.index == 0) // If Slider0 (Index = 0)
          {
            slider_val = genie.GetEventData(&Event); // Receive the event data from the Slider0
            genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, slider_val); // Write Slider0 value to to LED Digits 0
          }
        }
      }
    
    }
    Last edited by James_4DSystems; 14th March 2017, 07:19 AM. Reason: Added Code Box for readability - so you can compare to Post #3

  • #2
    Hello,

    Welcome to the forum.

    Well, the compile error I get with your code is simple, you have a semicolon after your #define RESETLINE 2 statement.

    Remove the semi colon and it compiles fine here.

    #define RESETLINE 2

    Regards
    James

    Comment


    • #3
      You however have more problems, outside of the compiling.

      you are missing the curly bracket after your loop function, before the void genieMyEventHandler(void); statement.

      and again the starting curly bracket after that statement.
      You then have a semi colon after that statement, which shouldnt be there...

      Try this:

      Code:
      #include <genieArduino.h>
      
      Genie genie;
      
      #define RESETLINE 2
      int ost;
      
      void setup() { 
      // put your setup code here, to run once:
        Serial.begin(200000);
        genie.Begin(Serial);
      
        genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events 
      
        pinMode(RESETLINE, OUTPUT);
        digitalWrite(RESETLINE, 1);
        delay(100);
        digitalWrite(RESETLINE, 0);
        delay(5000);
        genie.WriteContrast(7);
      }
      
      void loop() {
        // put your main code here, to run repeatedly;
        genie.DoEvents();
      
        //ost=41;
        genie.WriteObject (GENIE_OBJ_USER_LED, 0, 1);
        genie.WriteObject (GENIE_OBJ_COOL_GAUGE, 0, 10);
        //genie.ReadObject (GENIE_OBJ_SLIDER, 0);
        //genie.WriteObject (GENIE_OBJ_LED_DIGITS, 0, ost); This Worked
      }
      
      void myGenieEventHandler(void)
      {
        genieFrame Event;
        genie.DequeueEvent(&Event);
      
        int slider_val = 0;
        if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
        {
          { Event.reportObject.object == GENIE_OBJ_SLIDER; // If the Reported Message was from a Slider
      
            if (Event.reportObject.index == 0) // If Slider0 (Index = 0)
            {
              slider_val = genie.GetEventData(&Event); // Receive the event data from the Slider0
              genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, slider_val); // Write Slider0 value to to LED Digits 0
            }
          }
        }
      }
      James

      Comment


      • #4
        Many thanks for your fast response but unfortunately it still won't work with either of my Due boards but works a treat with a Uno.
        Regards
        Jue

        Comment


        • #5
          You are going to have to be more specific about what 'doesnt work'.

          Are you getting a compile error, or it just doesnt run as you expect, or something else?

          please provide more information

          Regards
          James

          Comment


          • #6
            Hi, sorry, it compiles OK for the Due and seems to download ok. The Display shows the Reset, the new Contrast Setting and the Cool Gauge reads a value as expected (10) The User led turns on but the Led digits do not show the value of the Slider.
            When I compile and download to a Uno it all works fine. I was about to try a different Serial port ?
            Regards
            Jue

            Comment


            • #7
              Please can you post your WS4 application so I can try it here.

              Zip the project up using File - Zip inside Workshop4, and attach the zip file to the forum

              Thanks
              James

              Comment


              • #8
                Many thanks for your help. I have solved the problem (At last) I changed the serial port by using separate header wires and all works ok now. (Using Serial 2)
                Not sure why it didn't like Serial 0 but it is now working
                Just need to expand it to run my whole project.
                Once again thank you for a very quick reply.
                Regards
                Jue

                Comment

                Working...
                X