ESP32 and APA 102

Hello everyone ,

My name Martien and i live in The Netherlands in Europe.

This is a video with an example that i like to use in my project.

And this is the code; (for a NodeMCU and a ESP8266 ledstrip)

#include “NeoPixelBus.h” // Library to control Pixel Stick
#include <WiFi.h> //“ESP8266WiFi.h” // WiFi Library

#define PixelCount 8 // Number of leds on stick
// I wil change it later on to 60 leds.

#define PixelPin 2
// NodeMCU pin 2 (RX) connected to Digital In of Pixel Stick

const char* ssid = “xxxxxxx”; // Name of WiFi Network
const char* password = “xxxxxxx”; // Password of WiFi Network

int firstrun = 0; // Check if system was just powered on
int buttonpressed = 5; // To hold which button was pressed on Web Page

// Initialize Library
//NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

// Define Arrays for colors
long switchled00 =
{
0x0E5219, 0x52160E, 0x0E5219, 0x52160E,0x0E5219,0x52160E,0x0E5219,0x52160E
};

long switchled01 =
{
0x19257B, 0x7B7A19, 0x19257B, 0x7B7A19, 0x19257B, 0x7B7A19, 0x19257B, 0x7B7A19
};

WiFiServer server(80); // Define Web Server Port

void setup() {
Serial.begin(115200);
delay(10);

//strip.Begin(); // Init of Pixel Stick
//strip.Show(); // Clears any lit up Leds

// Connect to WiFi network
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);

// Wait until connected to WiFi
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}

// Confirmation that WiFi is connected
Serial.println("");
Serial.println(“WiFi connected”);

// Start the Web Server
server.begin();
Serial.println(“Web Server Started”);

// Display IP address
Serial.print("You can connect to the Server here: ");
Serial.print(“http://”);
Serial.print(WiFi.localIP());
Serial.println();
Serial.println();

}

void loop() {

// Check if someone is connected
WiFiClient client = server.available();
if (!client) {
return;
}

// Read which button was pressed on the Web Page
String request = client.readStringUntil(’\r’);

// Light Up leds based on the button pressed
if (request.indexOf("/REDGREEN=1") != -1) {
for (int led = 0; led < 8; led++) {
//strip.SetPixelColor(led, HtmlColor(switchled00[led]));
}
//strip.Show();
buttonpressed = LOW;
firstrun=1;
}
if (request.indexOf("/BLUEYELLOW=1") != -1) {
for (int led = 0; led < 8; led++) {
//strip.SetPixelColor(led, HtmlColor(switchled01[led]));
}
//strip.Show();
buttonpressed = HIGH;
firstrun=1;
}

// Create Web Page
client.println(“HTTP/1.1 200 OK”); // HTML Header
client.println(“Content-Type: text/html”);
client.println("");
client.println("");
client.println(""); // Start of HTML
client.println("");
client.println(“body {background-color: #ACAEAD;}”); // Set Background Color
client.println("");

if (firstrun == 0) {
client.print("Please Click a Button ");
}
else {
client.print("Last Button Pressed was ");
}

if(buttonpressed == LOW) {
client.print(“Red & Green”);
}
if (buttonpressed == HIGH){
client.print(“Blue & Yellow”);
}
client.println("

“);
client.println(”<a href="/REDGREEN=1"">Red & Green “);
client.println(”<a href="/BLUEYELLOW=1"">Blue & Yellow
“);
client.println(”");
delay(10);

I have a ESP 32 board and a APA 102 ledstrip with 4 wires instead of 3.
That’s why i have to change the code for a APA 102.
I also want to directly access the ‘webpage’ of the ESP 32 without the external router in my house.
This can also be done with; WiFi.softAP (ssid, password). (I believe…)
To controle the leds i use a android device,trough WiFi.

In this example, the LEDs light up in Red / Green and Yellow / Blue.
That part of the code can remain the same (if possible) because i want to add more colors later on.
I also want the same design as the Arrays.
The layout of the webpage may also be the same.
(also both if possible)

I can also program a little bit myself, but not enough to do the whole thing.
At this moment i don’t have the time to learn it because i want to use it as soon as possible. (for a photography project this summer in 2018)

Your input is therefore more than welcome.

Thanks in advance !

Martien.

picturemaker:
At this moment i don’t have the time to learn it because i want to use it as soon as possible. (for a photography project this summer in 2018)

You want it now, but can't be bothered to learn how to do it yourself? Good luck with that. Sounds like you need to hire a programmer and pay them money to do what you want.

There are multiple libraries for the APA102 that provide a similar interface to the neopixel/WS2812 libraries. Google will find them for you. It should be a simple matter to switch to one of these libraries. Of course, that presumes basic familiarity with Arduino and C - if you don't have that, you should plan to pay someone to write your code for you.

Remember that you can't power more than a few of those LEDs directly from Arduino power supply (at least at full brightness) - 8 is already pushing it. (this is true regardless of which kind of RGB led you're using - at 20mA per channel you hit the 500mA limit pretty fast; this limit is lower if using the barrel jack to power it, due to the regulator overheating).