Skip to content

Arduino commands through C++ in Linux #2022

@aakarm89

Description

@aakarm89

Hi,

I am working on a project with the UDOO board. The board has Ubuntu loaded on it as the main OS. It also has a Arduino DUE attached with it.

I wanted to confirm if we can use the Arduino commands in the C++ language if I have, "#include Arduino.h" in the code?? This is what I mean by using Arduino commands

/* Program to read data from the encoders.
This file is to read data and calculate velocity. encoder.cpp
*/

#include <iostream.h>
#include <Arduino.h>

void setup(){
        pinMode(encoder0PinA, INPUT); 
    digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor
    pinMode(encoder0PinB, INPUT); 
}

void main(){
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
      encoder0Pos++;
    } else {
      encoder0Pos--;
    }

    Serial.println (encoder0Pos, DEC);
}

// End of Program 

Can I run a C++ code using the arduino header file on the GNU compiler of Linux?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions