|
6 | 6 | License: MIT. See license file for more information but you can |
7 | 7 | basically do whatever you want with this code. |
8 | 8 |
|
9 | | - This blinks a given IO pin to verify we have digitalWrite |
10 | | - control of every pin. |
11 | | - |
| 9 | + This blinks alternating pins to verify we have digitalWrite |
| 10 | + control of every pin (and no shorts between pins). Useful for initial hardware testing but |
| 11 | + otherwise a pretty boring sketch. |
| 12 | +
|
12 | 13 | Feel like supporting open source hardware? |
13 | 14 | Buy a board from SparkFun! |
14 | 15 | SparkFun Edge: https://www.sparkfun.com/products/15170 |
15 | 16 |
|
16 | 17 | Hardware Connections: |
17 | | - Connect an Edge via FTDI programmer |
| 18 | + Connect an Edge via serial programmer |
18 | 19 | Upload code |
19 | 20 | Verify GPIOs are going high/low every 2 seconds |
20 | | - */ |
| 21 | +*/ |
21 | 22 |
|
22 | | -#define testPin 33 |
23 | | - |
24 | | -#define LED 5 //On board LED is on pin 5 |
| 23 | +byte pinsToToggle = 0; |
25 | 24 |
|
26 | 25 | void setup() { |
27 | | - Serial.begin(115200); |
28 | | - Serial.println("SparkFun Arduino Apollo3"); |
| 26 | + Serial.begin(9600); |
| 27 | + |
| 28 | +#ifdef ARDUINO_AM_AP3_SFE_BB_ARTEMIS |
| 29 | + Serial.println("SparkFun BlackBoard Artemis"); |
| 30 | + pinsToToggle = 30; |
| 31 | +#elif AM_AP3_SFE_BB_ARTEMIS_NANO |
| 32 | + Serial.println("SparkFun BlackBoard Artemis Nano"); |
| 33 | + pinsToToggle = 20; |
| 34 | +#elif AM_AP3_SFE_BB_ARTEMIS_MEGA |
| 35 | + Serial.println("SparkFun BlackBoard Artemis Mega"); |
| 36 | + pinsToToggle = 50; |
| 37 | +#else |
| 38 | + Serial.println("Unknown board."); |
| 39 | + pinsToToggle = 10; |
| 40 | +#endif |
29 | 41 |
|
30 | | - pinMode(testPin, OUTPUT); |
31 | | - pinMode(LED, OUTPUT); |
| 42 | + Serial.printf("Toggling %d pins\n\r", pinsToToggle); //My goodness it's nice to have printf again |
| 43 | + |
| 44 | + Serial.println("pinMode will override the serial configuration so no more printing..."); |
| 45 | + |
| 46 | + for(int x = 0 ; x < pinsToToggle ; x++) |
| 47 | + { |
| 48 | + pinMode(x, OUTPUT); |
| 49 | + } |
32 | 50 | } |
33 | 51 |
|
34 | 52 | void loop() { |
35 | | - Serial.println("Toggle"); |
36 | | - |
37 | | - digitalWrite(testPin, LOW); |
38 | | - digitalWrite(LED, LOW); |
| 53 | + for(int x = 0 ; x < pinsToToggle ; x++) |
| 54 | + { |
| 55 | + if(x % 2 == 0) digitalWrite(x, LOW); |
| 56 | + else digitalWrite(x, HIGH); |
| 57 | + } |
39 | 58 | delay(2000); |
40 | 59 |
|
41 | | - digitalWrite(testPin, HIGH); |
42 | | - digitalWrite(LED, HIGH); |
| 60 | + for(int x = 0 ; x < pinsToToggle ; x++) |
| 61 | + { |
| 62 | + if(x % 2 == 0) digitalWrite(x, HIGH); |
| 63 | + else digitalWrite(x, LOW); |
| 64 | + } |
43 | 65 | delay(2000); |
44 | 66 | } |
0 commit comments