Command line style

The quickest way to get going with Arduino sketches is to start with the samples so you have a ‘template’ to guide you.

For parts of this guide to work, your pcDuion8 Uno needs to be connected to the Internet and you also need a terminal session running on the pcDuion8 Uno.

Setup(one time)

Run the commands to get the c_environment repository specially for pcDuino8 Uno :

cd ~ 
git clone https://github.com/pcduino/pcduino8_uno_lib

Cloning into 'pcduino8_uno_lib'...
remote: Counting objects: 151, done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 151 (delta 38), reused 151 (delta 38), pack-reused 0
Receiving objects: 100% (151/151), 267.89 KiB | 132.00 KiB/s, done.
Resolving deltas: 100% (38/38), done.
Checking connectivity... done.

Note: When you git clone some repositories from Github, maybe you will get an error like:

You can take these commands to avoid the error.

echo 'export GIT_SSL_NO_VERIFY=true' >> ~/.bashrc 
source ~/.bashrc

Then run command to download repository from Github again, like:

git clone https://github.com/pcduino/pcduino8_uno_lib

Initial Look Around

You should now have a folder called pcduino8_uno_lib. You can check by typing : ls -l pcduino8_uno_lib

samples folder saves the samples source codes.

hardware folder saves the hardware related functions and headers.

libraries folder saves the libraries related I2C, SPI and so on.

output folder will be created when you run make command to compile libraries and samples source code, and it saves the executable binary file.

Change into the pcduino8_uno_lib folder and run make to make the libraries and the samples:

cd pcduino8_uno_lib
make

Create a new program

Create new test.c file in samples folder and modify Makefile to compile it. For example I want to create helloLibArduino.c to control an LED on GPIO13.

vim samples/test.c

test source code

#include <core.h>
int led_pin = 13;

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

void loop()
{
  digitalWrite(led_pin, HIGH); // Turn the LED on
  delay(1000); // Wait for a second
  digitalWrite(led_pin, LOW); // Turn the LED off
  delay(1000); // Wait for a second
}

Modify Makefile

vim samples/Makefile

Add a line after OBJS=... and add the name of your program (without .c).

OBJS = i2c_rtc_test spi_nfc_test adc_test led_test
OBJS += test

Compile and run

Run make to compile test source code, then run it.

make
./output/test

This program will blink LED1 on pcDuino8 Uno.

results matching ""

    No results matching ""