Skip to main content
added 6 characters in body
Source Link

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

#include "arduino.h" 


int main(){

    pinMode(13, OUTPUT);

int main(){

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

We have to write it using functions defined in arduino.

void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

#include "arduino.h"

pinMode(13, OUTPUT);

int main(){

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

We have to write it using functions defined in arduino.

void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

#include "arduino.h" 


int main(){

    pinMode(13, OUTPUT);

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

We have to write it using functions defined in arduino.

void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

added 78 characters in body
Source Link
chrisl
  • 16.6k
  • 2
  • 18
  • 27

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

''' #include "arduino.h"

pinMode(13, OUTPUT);

int main(){

#include "arduino.h"

pinMode(13, OUTPUT);

int main(){

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

} '''

We have to write it using functions defined in arduino.

''' void setup(){ pinMode(13, OUTPUT); }

void loop(){ digitalWrite(13, HIGH); ..... } '''

void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

''' #include "arduino.h"

pinMode(13, OUTPUT);

int main(){

while(1){
digitalWrite(13, HIGH);
.....
}

} '''

We have to write it using functions defined in arduino.

''' void setup(){ pinMode(13, OUTPUT); }

void loop(){ digitalWrite(13, HIGH); ..... } '''

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

#include "arduino.h"

pinMode(13, OUTPUT);

int main(){

    while(1){
    digitalWrite(13, HIGH);
    .....
    }
}

We have to write it using functions defined in arduino.

void setup(){
    pinMode(13, OUTPUT);
}

void loop(){
    digitalWrite(13, HIGH);
    .....
}

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.

Source Link

How to write arduino code in a c/c++ script

I'm pretty new to arduino. But I have some knowledge about programming in c/c++. I know that arduino is written in c. But it can't be used as normal c/c++ code. for example , instead of including some libraries and write the code like this..

''' #include "arduino.h"

pinMode(13, OUTPUT);

int main(){

while(1){
digitalWrite(13, HIGH);
.....
}

} '''

We have to write it using functions defined in arduino.

''' void setup(){ pinMode(13, OUTPUT); }

void loop(){ digitalWrite(13, HIGH); ..... } '''

But I have some other libraries and programmes and stuff written in c and c++ and I need to use some arduino code in it and compile. So my question is, is there a way to write arduino in pure c/c++ as in first code snippet.

*I may not need arduino for this. My main target is to use servos, sensors in programms written in c/c++. But I would like to know what is the best way.