User Tools

Site Tools


drive_kard_sketches

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

drive_kard_sketches [2019/08/17 15:04] (current)
Line 1: Line 1:
 +Here is a sample blink sketch for that will control the outputs of a Drive Kard.  This sketch should run in any version of MPIDE that lists the Quick240 in the boards menu.
 +
 +<code cpp Quick240 Drive Kard Blink.pde>​
 +/*
 +  Blink
 +  Turns on an LED on for one second, then off for one second, repeatedly.
 + 
 +  This example code is in the public domain.
 + */
 + 
 +// KardCxPx is a multi-dimensional array where the first
 +// index points the Kard slot and the second point to the
 +// GPIO pin on the Kard, the first four GPIO pins generaly
 +// connect to the rail pin Px.
 +uint8_t KardCxPx[7][6] = {
 +                    { 68, 58, 62, 55, 82, 32 }, // Kard 0
 +                    { 57, 56, 63, 54, 83, 31 }, // Kard 1
 +                    { 86, 64,  5, 70, 84, 30 }, // Kard 2
 +                    { 22, 76,  9,  2, 35, 52 }, // Kard 3
 +                    { 23, 39,  8, 21, 34, 29 }, // Kard 4
 +                    { 78, 79, 10, 20, 33, 85 }, // Kard 5
 +                    { 0, 1, 19, 18, 71, 44 }, // Kard Com
 +                   };
 +
 +void setup() {
 +  // Set pins low before setting data direction to prevent
 +  // pins from driving before we are ready to drive
 +  digitalWrite(KardCxPx[0][0],​ LOW);   // set the LED off
 +  digitalWrite(KardCxPx[0][1],​ LOW);   // set the LED off
 +  digitalWrite(KardCxPx[0][2],​ LOW);   // set the LED off
 +  digitalWrite(KardCxPx[0][3],​ LOW);   // set the LED off
 +  // Set the digital pins as an output.
 +  pinMode(KardCxPx[0][0],​ OUTPUT); ​    
 +  pinMode(KardCxPx[0][1],​ OUTPUT); ​    
 +  pinMode(KardCxPx[0][2],​ OUTPUT); ​    
 +  pinMode(KardCxPx[0][3],​ OUTPUT); ​    
 +}
 +
 +void loop() {
 +  long time_ms = 250;
 +  digitalWrite(KardCxPx[0][0],​ HIGH); ​ // set the LED on
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][1],​ HIGH); ​ // set the LED on
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][2],​ HIGH); ​ // set the LED on
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][3],​ HIGH); ​ // set the LED on
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][0],​ LOW);   // set the LED off
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][1],​ LOW);   // set the LED off
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][2],​ LOW);   // set the LED off
 +  delay(time_ms); ​                     // wait for a second
 +  digitalWrite(KardCxPx[0][3],​ LOW);   // set the LED off
 +  delay(time_ms); ​                     // wait for a second
 +}
 +</​code>​
  
drive_kard_sketches.txt ยท Last modified: 2019/08/17 15:04 (external edit)