Jump to content
Sign in to follow this  
smily03

Multitasking the "arduino" functionality

Recommended Posts

I noticed something odd this evening. It doesn't look like the "arduino" functionality of the PCD8 can multitask?

 

Basically - I added a "heartbeat" binary to my PCD so that I can, at a glance, see whether it's responding. This is the same basic functionality as is on my beaglebone and odroid. The binary is set to load on each reboot automatically via a cron job:

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

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

void loop() {
  digitalWrite(led_pin, HIGH);  // set the LED on
  delay(100);                                  // wait for a second
  digitalWrite(led_pin, LOW);       // set the LED off
  delay(400);                                  // wait for a second
  digitalWrite(led_pin, HIGH);  // set the LED on
  delay(100);                                  // wait for a second
  digitalWrite(led_pin, LOW);       // set the LED off
  delay(1000);                                  // wait for a second
}

The heartbeat blinker works fine. However, when I try to do something else, like blink an LED attached to each of the digital pins, one after the other, the output is interrupted by each "blink" of the blink binary...?

#include <core.h>

void setup() {
  for (int p=0; p < 13; p++) {
    pinMode(p, OUTPUT);
  }
}

void loop() {
  for (int pin=0; pin < 13; pin++) {
    digitalWrite(pin, HIGH);  // set the LED on
    delay(1000);                                  // wait for a second
    digitalWrite(pin, LOW);       // set the LED off
    delay(1000);
  }
}

Eg. -- each time the onboard LED blinks, the other LEDs turn off: https://drive.google.com/open?id=0B7V-geo_F_GyWi0yWHlza2QyelE

 

However, if the blink binary isn't running at the time, it works properly: https://drive.google.com/open?id=0B7V-geo_F_GyQ1k2MGpURFpYaDA

 

That seems odd and sort of annoying...

 

 

Share this post


Link to post
Share on other sites

for (int pin=0; pin 13; pin++) {
digitalWrite(pin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(pin, LOW); // set the LED off
delay(1000);
}

for this logic, every 13x2 s, each GPIO will blink one time, that's you want to implement, right?

Share this post


Link to post
Share on other sites

Not really. Basically what the code does is iterate through each digital pin one after the other. For each pin, it turns on, waits a second, then turns off, then waits a second.

 

But when a second process is writing to other pins, you can see from the videos that it interrupts the other processes (hence the sporadic blinking.)

Share this post


Link to post
Share on other sites
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×