How to Run PWM on Raspberry Pi 3 with blynk library and wiringPi C?

Hello, I need help with my project that involves controlling a DC motor using L298N on my raspberry pi 3 with C . But I am at a complete standstill, the motor won’t run no matter what I do. I tried to control it with python and it worked flawlessly, here’s the C code

[Unformatted code removed by moderator]

I DESPRETLYYY NEED HELPPPP

Thanks!!!

You desperately need to add triple backticks at the beginning and end of your code, otherwise it will be deleted!
Triple backticks look like this:
```

Pete.

Hello PeteKnight
Thanks for replying, though i don’t think I got what you mean. Putting triple backticks on the top and the bottom of my code gave me this error when building.

main.cpp:3:1: error: stray ‘`’ in program

^
main.cpp:3:2: error: stray ‘`’ in program

^
main.cpp:3:3: error: stray ‘`’ in program

  ^
main.cpp:71:1: error: stray ‘`’ in program

^
main.cpp:71:2: error: stray ‘`’ in program

 ^
main.cpp:71:3: error: stray ‘`’ in program

Triple backticks are required when you post code to this forum, so that it displays correctly.
This is explained fully when you create a new topic, along with the information that incorrectly posted code will be deleted by the moderators.
Please use the pencil icon at the bottom of your first post in this thread to edit your post and add in the triple backticks.

Pete.

Oh that’s what you mean, sorry

Here’s the code

// Blynk "gp" numbers are BCM numbers, so gp17 is physical pin 11 
// #define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
 #include <BlynkApiWiringPi.h>
#else
 #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

#define Fr 5
#define Bc 6
#define analogOutPin 18

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

#include <BlynkWidgets.h>

void myTimerEvent()       		// button widget on V0 or direct access gp17 button
{
        digitalWrite(Fr, HIGH); digitalWrite(Bc, LOW); analogWrite(analogOutPin, 300);
}

void loop()
{
  Blynk.run();
  myTimerEvent();
}

int main(int argc, char* argv[])
{
    const char *auth, *serv;
    uint16_t port;
    parse_options(argc, argv, auth, serv, port);
    Blynk.begin(auth, serv, port);
    while(true) {
		loop();
    }
    return 0;
}

Thank you.
It’s a pity that you didn’t do as I asked and edited your original posy, but I’ve deleted the code from that post to tidy things up a bit.

Pete.

Oh, I apologize. I am very new to this part of the forum. But now that I know how the forum works, any idea of what is happening to my code? I printed out he status of my Fr and BC pins and they are HIGH and LOW as they should be. But the analogOinOut is “0” when I printed it.

Your issue is not Blynk specific… rather additional setup with WiringPi is needed… Google helps :slight_smile:

http://wiringpi.com/reference/software-pwm-library/

WiringPi is also soon depreciating. I recommend learning and using NodeJS and/or Python with Blynk and RPi devices.

I’m stucked with nodejs…