Announcement

Collapse
No announcement yet.

Need Help for keyboard input

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

  • Need Help for keyboard input

    Hey my problem is to change this in my Arduino sketch via the keyboard Input!

    float seaLevelPressure = 1026.70; //edit to SLP for your location wanna also use for genie Input via Keyboard? //

    i know i have to use the event handler , but im stuck here.

    I have created a keyboard input 0-9 and a string Object


  • #2
    Hi,

    This application note should help you understand arduino printing so string objects via keyboard:

    http://www.4dsystems.com.au/appnote/4D-AN-00188/

    This application note shows how to write a sketch for an Arduino program that prints characters on string object from keyboard object to create a simple Password Implemented Application
    Symon

    Comment


    • #3
      Hey my input from keyboard is working (Without dot i need also )and also print out.as keyvalue
      So far so Good, but not changed in Arduino Teensy 3.1 for the new calculation and i dont know how to do that

      My serial Printout from Serial.println(keyvalue[x]);
      -----------------------------------------------------------------------------------
      1
      0
      2
      0
      DONE
      ---------------------------------------------------------------------------------------------

      keyvalue is a char and i wanna change to float sealevelPressure !


      float seaLevelPressure = 1026.70; //edit to SLP for your location wanna also use for genie Input via Keyboard? //


      But how can i do this after this process Arduino Teensy 3.1 should change this to a new calculate for Altitude!


      And how can i use the (. dot) in code? with this code given 0-9 back and return works?


      Need Help




      Here is my code:


      Code:
      void myGenieEventHandler(void)
      {
       
        genieFrame Event;
        genie.DequeueEvent(&Event);
      
        //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
        if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
        {
          if(Event.reportObject.object == GENIE_OBJ_KEYBOARD)
          {
            if (Event.reportObject.index == 0)                              // If keyboard0
            {
              temp = genie.GetEventData(&Event); 
              if(temp >= 48 && temp <= 57 && counter <=9)
              {
                keyvalue[counter] = temp;        // Receive the event data from the keyboard
                genie.WriteStr(3,keyvalue);                         //prints to String Object       
                counter = counter + 1; //increment array
              }
              else if(temp == 8)                              //check if backspace
              {
                counter--;
                keyvalue[counter] = 0;
                genie.WriteStr(3,keyvalue);
              }
              else if(temp == 13)
              {
                for(int x =0; x<counter ; x++)
                {
                Serial.println(keyvalue[x]);
                  
                  
                }
                Serial.print("DONE");
                //Serial.print(String(slp.toFloat());
               // char *keyvalue[x] = slp;
              // float seaLevelPressure = char keyvalue; 
                      
                genie.WriteObject(GENIE_OBJ_FORM,0x05,0);
              }
            }
          }
        }
      }

      Comment


      • #4
        Ok the failure with .dot is char 110 but printed as an "n" is that right?

        if(temp >= 48 && temp <= 110 && counter <=9) // Recognize only number 1-9 change this to 48-122 if Qwerty

        1022n00 for 1022.00 ? im confused

        Last edited by ADVANCETOM; 4th October 2015, 03:05 AM.

        Comment


        • #5
          AHHHHHHHHHHHHHHH

          i found a solution and it works

          i set

          double n;

          in main loop:

          float seaLevelPressure = n;


          But this was the solution


          n = atof (keyvalue); //printout 1022.00 great

          Thats my GenieEventHandler routine for anybody who wants it to use




          void myGenieEventHandler(void)
          {

          genieFrame Event;
          genie.DequeueEvent(&Event);

          //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
          if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
          {
          if(Event.reportObject.object == GENIE_OBJ_KEYBOARD)
          {
          if (Event.reportObject.index == 0) // If keyboard0
          {
          temp = genie.GetEventData(&Event);
          if(temp >= 48 && temp <= 110 && counter <=9) // Recognize only number 1-9 change this to 48-122 if using a QWERTY Keyboard
          {
          keyvalue[counter] = temp; // Receive the event data from the keyboard
          genie.WriteStr(3,keyvalue); //prints to String Object
          counter = counter + 1; //increment array
          }
          else if(temp == 8) //check if backspace
          {
          counter--;
          keyvalue[counter] = 0;
          genie.WriteStr(3,keyvalue);
          }
          else if(temp == 13)
          {
          for(int x =0; x<counter ; x++)
          {
          Serial.println(keyvalue[x]); //so you can see the captured string


          }
          Serial.println("DONE");

          n = atof (keyvalue);
          Serial.println(n);

          genie.WriteObject(GENIE_OBJ_FORM,0x05,0);
          }
          }
          }
          }
          }



          PS:Will attach Video soon
          Last edited by ADVANCETOM; 4th October 2015, 05:44 AM.

          Comment


          • #6
            Here is the Video link:
            ENJOY .)


            http://1drv.ms/1j6GSP8

            Comment


            • #7
              Thank you ADVANCETOM.
              even after all this time yours is the only example of using the keyboard object for Arduino I could find.

              Comment


              • #8
                Hello Paulkid,

                It's nice that you've figure it out.
                If you have more questions and examples
                you can always reach our forum.

                Best regards,
                Bern

                Comment

                Working...
                X