In this example we will connect 6 LEDs to a Shield Shield for Spark Core and flash them on and off
The Photon is a tiny Wi-Fi development kit for creating connected projects and products for the Internet of Things. It’s easy to use, powerful and connected to the Cloud. The tools that make up the Photon’s ecosystem are designed to let you build and create whether you’re an embedded engineer, web developer, Arduino enthusiast or IoT entrepreneur.
You’ll be able to write your firmware in our web or local IDE, deploy it over the air and build your web and mobile apps with ParticleJS and our Mobile SDK. The board itself uses a Broadcom Wi-Fi chip alongside a powerful STM32 ARM Cortex M3 microcontroller. It’s like the Spark Core, but better.
The shield is an adaptor which will allow you to connect an Arduino shield to a Particle Photon
The shield uses Texas Instruments TXB0108PWR to do voltage conversion in between the Spark Core’s 3.3V logic level and the Arduino’s 5V logic.
Parts List
Part | Link |
Particle Core Photon | Particle Core Photon WiFi Development Board BCM43362 STM32F205 ARM Cortex M3 for the Internet of Things IoT |
Shield Shield for Spark Core | SPARK CORE ARDUINO SHIELD ADAPTOR Development Boards & Evaluation Kits |
LED Test board | Link to test board |
Connection
The shield shield does not map one to one to the Arduino connections, the LED test board we use will use Arduino pins 8 to 13.
Arduino pin | Spark Core pin |
0 | RX |
1 | TX |
2 | D2 |
3 | D0 |
4 | D3 |
5 | D1 |
6 | A7 |
7 | D4 |
8 | D5 |
9 | D6 |
10 | A2 |
11 | A5 |
12 | A4 |
13 | A3 |
A0 | A0 |
A1 | A1 |
A2 | A6 |
Code
The code is written in the https://build.particle.io – the code will be very familiar for people who use the Arduino IDE, you can also flash your device using the IDE
[codesyntax lang=”cpp”]
/* Arduino - Shield shield 8 D5 9 D6 10 A2 11 A5 12 A4 13 A3 */ int led1 = D5; int led2 = D6; int led3 = A2; int led4 = A5; int led5 = A4; int led6 = A3; void setup() { // We are going to tell our device that D0 and D7 // It's important you do this here, inside the setup() function rather than outside it or in the loop function. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(led6, OUTPUT); } // Next we have the loop function, the other essential part of a microcontroller program. void loop() { // To blink the LED, first we'll turn it on... digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); digitalWrite(led4, HIGH); digitalWrite(led5, HIGH); digitalWrite(led6, HIGH); // We'll leave it on for 1 second... delay(1000); // Then we'll turn it off... digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); digitalWrite(led4, LOW); digitalWrite(led5, LOW); digitalWrite(led6, LOW); // Wait 1 second... delay(1000); // And repeat! }
[/codesyntax]
Video
A video of the example above in action