2 Replies Latest reply on Nov 3, 2015 4:15 PM by annu_shah

    PWM ON MRAA

    annu_shah

      hi i am following this link mraa/Pwm3-cycle.cpp at master · intel-iot-devkit/mraa · GitHub

      i am trying to understand this part of the code :-

       

        value = value + 0.01f;
        pwm->write(value);
         usleep(50000);
         if (value >= 1.0f) {
        value = 0.0f;

       

      it means that the pwm works from values 0 to 1

       

       

      i am outputing the pwm values so i add this code:-

       

       

      float output=0.0f;

          float value = 0.0f;

          while (running == 0) {

              value = value + 0.01f;

              pwm->write(value);

       

       

              output= pwm->read();

              printf("value written on the pin : %d\n",value);

              printf("output on pin 3 : %d\n",output);

              usleep(5000000);

              if (value >= 1.0f) {

                  value = 0.0f;

              }

          }

       

      this is the output i get i was trying to understand the values but they seem quite random :-

       

       

      27.png

       

       

       

       

       

       

       

      Basically i am trying to convert this arduino ide code in mraa

       

      for (int i=0;i<255;i++){

         

               // scale it to use it with the servo (value between 0 and 180)

          myservoM.write(i);                  // sets the servo position according to the scaled value

      }

      here it has a range from 0-255

       

      so will the mraa code work