#include <core.h>
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
}
void loop() {
// put your main code here, to run repeatedly:
while (Serial.available () > 0){
char c = Serial.read ();
Serial.print (c);
printf ("%c",c);
fflush (stdout);
}
}
Run the program:
![]()
Windows 1, 2 and 3 are Arduino IDE on pcDuino3, running terminal window on pcDuino3 and serial terminal on host computer respectively. By looking at windows 2 and 3, we find that when we enter “hello LinkSprite!!!” in terminal 2, pcDuino received the message , and sent to the PC, and PC displayed the message on window 3.
PWM of pcDuinoV3:
Connect a Linker LED module to the PWM port of pcDuino through the Linker base shield, and using the PWM sample code, we can obtain a breathing LED.
IIC of pcDuino3:To test IIC, we can use a Linker RTC module, which has a chipset of DS1307. DS1307 communicates with the host through an IIC interface.
![]()
Launch the Arduino IDE that comes with pcDuino3, and navigate through File -> Examples -> 00.pcDuino -> 02.linker_kits -> linker_rtc_test :
![]()
Compile and run the program, enter the corresponding parameters in the terminal, and then the RTC module will start to time:
Interrupt of pcDuino3:
pcDuino3 is same as Arduino Uno in that the function attachInterrrupt can only use interrupts 0 and 1, which correspond to D2 and D3.
In this test, we apply a low level signal to D2, so pcDuino3 will generate an interrupt to turn on the LED that is attached to pin 4. The code is as below:
#include <core.h>
#define MAX_COUNT 30
#define INT_MODE FALLING
/* support two interrupts pin2/pin3, and default interrupt pins are pulled up*/
int led_pin0 = 5;
volatile int state0 = LOW;
int bc0 = 0;
void blink0()
{
state0 = !state0;
bc0++;
printf("blink0: %d, count=%drn", state0, bc0);
}
void setup()
{
pinMode(led_pin0, OUTPUT);
attachInterrupt(0, blink0, INT_MODE);
}
void loop()
{
digitalWrite(led_pin0, state0);
if (bc0 >= MAX_COUNT)
detachInterrupt(0);
delay(1000);
}

Leave a Reply
You must be logged in to post a comment.