Author Topic: My first sketch  (Read 1757 times)

exeng

  • Sr. Member
  • ****
  • Posts: 452
My first sketch
« on: February 11, 2016, 07:03:57 pm »
Seen a few posts on "how do I know my sketch loader / is working.

Well, assuming that you have successfully got your Oak setup and on particle and have run the Oak CLI in to select the Oak you are going to use to upload to, this first sketch (has not bricked) will put out a unique LED pattern that is distinct from the upload pattern.  If you are running it for the first time you will see a (about) 1/2 second LED duty cycle which is an indication of the upload, then a blank LED for a few seconds, then the unique LED flash pattern (slow to fast flash) running from setup(), then the slow 3 second duty cycle LED flash in loop(). Hasn't bricked and I am now confident that I can successfully upload using the Arduino IDE.  Hope this is useful to others. I am a happy camper. Here's to no bricking and on to more complex sketches.

NOTE: I'm using Particle.delay as required for the Oak.

The upload for this takes about 2 minutes on my net.

Here is the sketch...

#define OakLEDPin 1
void setup() {           
  // initialize the digital pin as an output.
  pinMode(OakLEDPin, OUTPUT); //Oak LED
  // Put out a unique LED pattern to indicate sketch start
  OakLEDRun(OakLEDPin);
}

// the loop routine runs over and over again forever:
void loop() {
  // slow blink
  digitalWrite(1, HIGH);   // turn the LED on (HIGH is the voltage level)
  Particle.delay(3000);             
  digitalWrite(1, LOW);    // turn the LED off by making the voltage LOW
  Particle.delay(3000);             
}

//Puts out a unique LED pattern to indicate sketch start
void OakLEDRun(int pin) {
  int i, n;
  for(n=0; n<3; n++) {
     for(i=0; i<3; i++) {
       digitalWrite(1, HIGH);   // turn the LED on
       Particle.delay(1000);           
       digitalWrite(1, LOW);    // turn the LED off
       Particle.delay(500);             
       digitalWrite(1, HIGH);   // turn the LED on
       Particle.delay(500);             
       digitalWrite(1, LOW);    // turn the LED off
       Particle.delay(250);             
       digitalWrite(1, HIGH);   // turn the LED on
       Particle.delay(250);           
       digitalWrite(1, LOW);    // turn the LED off
       Particle.delay(125);           
       digitalWrite(1, HIGH);   // turn the LED on
       Particle.delay(125);             
       digitalWrite(1, LOW);    // turn the LED off
       Particle.delay(60);             
        digitalWrite(1, HIGH);  // turn the LED on
       Particle.delay(60);             
       digitalWrite(1, LOW);    // turn the LED off
       Particle.delay(30);
     } // end for (i..)           
     Particle.delay(1000);
  } // end for(n...)
} // end OakLEDRun




« Last Edit: February 11, 2016, 07:54:11 pm by exeng »

stevech

  • Newbie
  • *
  • Posts: 1
Re: My first sketch
« Reply #1 on: February 11, 2016, 07:26:25 pm »
2 minutes? (realizing this is via USB/serial not WiFi)

Since Digistump is so very far behind schedule versus their July, 2015 hoop-la about partnering with Particle.io - ostensibly to avoid reinventing. Maybe this is not a lovely pairing. Feb. 2016 and no way to use the Particle IDE.

The Particle.io board I have does a wired download of a small program in a slow 30 seconds or so.  Even so, silly-slow for a 32 bit processor with megabit WiFi - and it could be in the WiFi ad-hoc (peer to peer) mode to simplify. Or associate to the WiFi LAN here and download from the local PC - to heck with the cloud's complexity.

Sounds like Oak is running the least prudent baud rate.

And/or Digistump is trying to do far too much with too few heads.
« Last Edit: February 11, 2016, 07:31:16 pm by stevech »

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: My first sketch
« Reply #2 on: February 11, 2016, 08:12:05 pm »
I'm not associated with Digistump. I'm just one of many Kickstarter backers that have received many working products from Digistump. Oak is in BETA and OTA updates are known to be slow as stated here:
https://github.com/digistump/OakCore/releases

"Known Issues with this release:
•OTA Updates are very slow! 2-3 minutes on average. When an OTA update is taking place the LED will blink somewhat erratically - one toggle per packet arriving. (This is Temporary - FastOTA will be turned on in a near future release)"

This is intended to be a temporary situation. With support and encouragement, improvements will come.





werner

  • Newbie
  • *
  • Posts: 37
Re: My first sketch
« Reply #3 on: February 11, 2016, 09:49:31 pm »
@exeng thank you very much for sharing this.  It was very useful to me, as it at least confirms uploading a sketch works and how long it takes and most importantly reminding me again that I need to run  the Oak CLI again to select  the Oak I want to program.  (I forgot to do this step after I start using a second Oak, and that is probably why my sketch did not work before) 

I can also report that I was also successful now in uploading your LED app :)
« Last Edit: February 12, 2016, 03:58:33 am by werner »