I would love to embed this python program on a c++ one , but I'm kinda struggling there , I never studied python , and even after reading the explanation in others websites about the method I couldn't really apply it , because I don't know what are those python members ,I want to run this program under c++, this code is a good one , but couldn't find it in c++ version , this is why I decided to use the embedded option .
here is the python program
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Le Raspbery Pi envoie des messages à l'Arduino
import serial # bibliothèque permettant la communication série
import time # pour le délai d'attente entre les messages
ser = serial.Serial('/dev/ttyACM0', 9600)
compteur = 0
while True: # boucle répétée jusqu'à l'interruption du programme
if compteur < 6:
compteur = compteur + 1
else:
compteur = 0
ser.write(str(compteur))
time.sleep(1) # on attend pendant 2 secondes
and here is the embedded program that I tried , but I'm pretty sure that its wrong , because there is no call of python object
#include <iostream>
#include <Python.h>
int main(int argc, char **argv) {
Py_Initialize();
return 0;
}
Can anybody help me to do this !? thanks in advance .