Daisy Seed LED code
https://wokwi.com/projects/416811506491807745
Something that I need to work out is if I can actually use the daisy seed to run this code. There is something called daisyduino that I need to look more into. https://github.com/electro-smith/DaisyDuino
This code works with Arduino !!! VVVVVVVVVVVVVVV
#include <FastLED.h>
#include <ezButton.h> // the library to use for SW pin
#define CLK_PIN 2
#define DT_PIN 3
#define SW_PIN 4
#define LED_PIN 7
#define NUM_LEDS 14 // Set the number of LEDs in the ring + 1
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
ezButton button(SW_PIN); // create ezButton object that attach to SW_PIN
CRGB leds[NUM_LEDS];
enum ColorState {
RED,
BLUE,
GREEN
};
ColorState currentColor = RED;
int counter = 0; // Current LED index
int CLK_state;
int prev_CLK_state;
// Define LED states
enum LEDState {
OFF,
HALF_BRIGHT,
FULL_BRIGHT
};
LEDState ledStates[NUM_LEDS]; // Array to hold the state of each LED
void setup() {
Serial.begin(9600);
pinMode(CLK_PIN, INPUT);
pinMode(DT_PIN, INPUT);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
prev_CLK_state = digitalRead(CLK_PIN);
// Initialize all LEDs to off
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
ledStates[i] = OFF; // Set all LEDs to OFF state
}
// Set the first LED to be always on
leds[0] = getColor(currentColor); // Set the first LED to the current color
ledStates[0] = FULL_BRIGHT; // Set its state to FULL_BRIGHT
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
unsigned long lastDebounceTime = 0; // Last time the output pin was toggled
const unsigned long debounceDelay = 100; // Delay for debounce
void loop() {
button.loop(); // MUST call the loop() function first
CLK_state = digitalRead(CLK_PIN);
// If the state of CLK is changed, then pulse occurred
if (CLK_state != prev_CLK_state && (millis() - lastDebounceTime) > debounceDelay) {
lastDebounceTime = millis(); // Reset the debounce timer
if (digitalRead(DT_PIN) == LOW) {
// Counter-clockwise direction
if (counter > 0) { // Ensure counter does not go below 0
// Handle CCW logic
if (ledStates[counter] == FULL_BRIGHT) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to off
leds[counter] = CRGB::Black;
ledStates[counter] = OFF;
//} else if (ledStates[counter] == OFF) {
// Move to the previous LED and set to full brightness
counter--;
if(counter > NUM_LEDS) {
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
}
}
}
} else {
// Clockwise direction
if (counter < NUM_LEDS - 1) { // Ensure counter does not exceed NUM_LEDS - 1
// Handle CW logic
if (ledStates[counter] == OFF) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to full brightness
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
} else if (ledStates[counter] == FULL_BRIGHT) {
// Move to the next LED and set to half brightness
counter++;
if (counter < NUM_LEDS) { // This check is now redundant but keeps the logic clear
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
}
}
}
}
Serial.print("COUNTER: ");
Serial.println(counter);
}
// Ensure the first LED is always on
leds[0] = getColor(currentColor);
ledStates[0] = FULL_BRIGHT;
// Update the LEDs
FastLED.show();
prev_CLK_state = CLK_state;
// Check if the button is pressed
if (button.isPressed()) {
Serial.println("Button Pressed!"); // Print message when button is pressed
changeColor();
}
}
// Function to get the current color based on the state
CRGB getColor(ColorState colorState) {
switch (colorState) {
case RED: return CRGB::Red;
case BLUE: return CRGB::Blue;
case GREEN: return CRGB::Green;
default: return CRGB::Black;
}
}
// Function to change the color state
void changeColor() {
currentColor = static_cast<ColorState>((currentColor + 1) % 3); // Cycle through RED, BLUE, GREEN
// Update all LEDs to the new color regardless of their state
for (int i = 0; i < NUM_LEDS; i++) {
// Change the color of the LED regardless of its state
if (leds[i].r == 0 && leds[i].g == 0 && leds[i].b == 0) {
// LED is off, just set its color without turning it on
leds[i] = getColor(currentColor).fadeToBlackBy(255); // Keep it off but set the color
} else if (ledStates[i] == HALF_BRIGHT) {
// LED is half-bright, change its color but keep it half-bright
leds[i] = getColor(currentColor).fadeToBlackBy(128); // Keep it at half brightness
} else {
// LED is fully bright, change its color
leds[i] = getColor(currentColor);
}
}
}](<#include %3CFastLED.h%3E
#include <ezButton.h> // the library to use for SW pin
#define CLK_PIN 2
#define DT_PIN 3
#define SW_PIN 4
#define LED_PIN 7
#define NUM_LEDS 14 // Set the number of LEDs in the ring + 1
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
ezButton button(SW_PIN); // create ezButton object that attach to SW_PIN
CRGB leds[NUM_LEDS];
enum ColorState {
RED,
BLUE,
GREEN
};
ColorState currentColor = RED;
int counter = 0; // Current LED index
int CLK_state;
int prev_CLK_state;
// Define LED states
enum LEDState {
OFF,
HALF_BRIGHT,
FULL_BRIGHT
};
LEDState ledStates[NUM_LEDS]; // Array to hold the state of each LED
void setup() {
Serial.begin(9600);
pinMode(CLK_PIN, INPUT);
pinMode(DT_PIN, INPUT);
button.setDebounceTime(75); // set debounce time to 50 milliseconds
prev_CLK_state = digitalRead(CLK_PIN);
// Initialize all LEDs to off
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
ledStates[i] = OFF; // Set all LEDs to OFF state
}
// Set the first LED to be always on
leds[0] = getColor(currentColor); // Set the first LED to the current color
ledStates[0] = FULL_BRIGHT; // Set its state to FULL_BRIGHT
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
unsigned long lastDebounceTime = 0; // Last time the output pin was toggled
const unsigned long debounceDelay = 50; // Delay for debounce
void loop() {
button.loop(); // MUST call the loop() function first
CLK_state = digitalRead(CLK_PIN);
// If the state of CLK is changed, then pulse occurred
if (CLK_state != prev_CLK_state && (millis() - lastDebounceTime) > debounceDelay) {
lastDebounceTime = millis(); // Reset the debounce timer
int new_CLK_state = digitalRead(CLK_PIN);
if (new_CLK_state == CLK_state) { // Confirm the state is stable
lastDebounceTime = millis(); // Reset the debounce timer
if (digitalRead(DT_PIN) == LOW) {
// Counter-clockwise direction
if (counter > 0) { // Ensure counter does not go below 0
// Handle CCW logic
if (ledStates[counter] == FULL_BRIGHT) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to off
leds[counter] = CRGB::Black;
ledStates[counter] = OFF;
//} else if (ledStates[counter] == OFF) {
// Move to the previous LED and set to full brightness
counter--;
if(counter > NUM_LEDS) {
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
}
}
}
} else {
// Clockwise direction
if (counter < NUM_LEDS - 1) { // Ensure counter does not exceed NUM_LEDS - 1
// Handle CW logic
if (ledStates[counter] == OFF) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to full brightness
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
} else if (ledStates[counter] == FULL_BRIGHT) {
// Move to the next LED and set to half brightness
counter++;
if (counter < NUM_LEDS) { // This check is now redundant but keeps the logic clear
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
}
}
}
}
Serial.print("COUNTER: ");
Serial.println(counter);
}
}
// Ensure the first LED is always on
leds[0] = getColor(currentColor);
ledStates[0] = FULL_BRIGHT;
// Update the LEDs
FastLED.show();
prev_CLK_state = CLK_state;
// Check if the button is pressed
if (button.isPressed()) {
Serial.println("Button Pressed!"); // Print message when button is pressed
changeColor();
}
}
// Function to get the current color based on the state
CRGB getColor(ColorState colorState) {
switch (colorState) {
case RED: return CRGB::Red;
case BLUE: return CRGB::Blue;
case GREEN: return CRGB::Green;
default: return CRGB::Black;
}
}
// Function to change the color state
void changeColor() {
currentColor = static_cast<ColorState>((currentColor + 1) % 3); // Cycle through RED, BLUE, GREEN
// Update all LEDs to the new color regardless of their state
for (int i = 0; i < NUM_LEDS; i++) {
// Change the color of the LED regardless of its state
if (leds[i].r == 0 && leds[i].g == 0 && leds[i].b == 0) {
// LED is off, just set its color without turning it on
leds[i] = getColor(currentColor).fadeToBlackBy(255); // Keep it off but set the color
} else if (ledStates[i] == HALF_BRIGHT) {
// LED is half-bright, change its color but keep it half-bright
leds[i] = getColor(currentColor).fadeToBlackBy(128); // Keep it at half brightness
} else {
// LED is fully bright, change its color
leds[i] = getColor(currentColor);
}
}
}>)](<#include %3CFastLED.h%3E
#include <ezButton.h> // the library to use for SW pin
#define CLK_PIN 2
#define DT_PIN 3
#define SW_PIN 4
#define LED_PIN 7
#define NUM_LEDS 14 // Set the number of LEDs in the ring + 1
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
ezButton button(SW_PIN); // create ezButton object that attach to SW_PIN
CRGB leds[NUM_LEDS];
enum ColorState {
RED,
BLUE,
GREEN,
YELLOW,
CYAN,
PURPLE
};
ColorState currentColor = RED;
int counter = 0; // Current LED index
int CLK_state;
int prev_CLK_state;
// Define LED states
enum LEDState {
OFF,
HALF_BRIGHT,
FULL_BRIGHT
};
LEDState ledStates[NUM_LEDS]; // Array to hold the state of each LED
void setup() {
Serial.begin(9600);
pinMode(CLK_PIN, INPUT);
pinMode(DT_PIN, INPUT);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
prev_CLK_state = digitalRead(CLK_PIN);
// Initialize all LEDs to off
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
ledStates[i] = OFF; // Set all LEDs to OFF state
}
// Set the first LED to be always on
leds[0] = getColor(currentColor); // Set the first LED to the current color
ledStates[0] = FULL_BRIGHT; // Set its state to FULL_BRIGHT
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
unsigned long lastDebounceTime = 0; // Last time the output pin was toggled
const unsigned long debounceDelay = 100; // Delay for debounce
void loop() {
button.loop(); // MUST call the loop() function first
CLK_state = digitalRead(CLK_PIN);
// If the state of CLK is changed, then pulse occurred
if (CLK_state != prev_CLK_state && (millis() - lastDebounceTime) > debounceDelay) {
lastDebounceTime = millis(); // Reset the debounce timer
int new_CLK_state = digitalRead(CLK_PIN);
if (new_CLK_state == CLK_state) { // Confirm the state is stable
lastDebounceTime = millis(); // Reset the debounce timer
if (digitalRead(DT_PIN) == LOW) {
// Counter-clockwise direction
if (counter > 0) { // Ensure counter does not go below 0
// Handle CCW logic
if (ledStates[counter] == FULL_BRIGHT) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to off
leds[counter] = CRGB::Black;
ledStates[counter] = OFF;
//} else if (ledStates[counter] == OFF) {
// Move to the previous LED and set to full brightness
counter--;
if(counter > NUM_LEDS) {
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
}
}
}
} else {
// Clockwise direction
if (counter < NUM_LEDS - 1) { // Ensure counter does not exceed NUM_LEDS - 1
// Handle CW logic
if (ledStates[counter] == OFF) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to full brightness
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
} else if (ledStates[counter] == FULL_BRIGHT) {
// Move to the next LED and set to half brightness
counter++;
if (counter < NUM_LEDS) { // This check is now redundant but keeps the logic clear
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
}
}
}
}
Serial.print("COUNTER: ");
Serial.println(counter);
}
}
// Ensure the first LED is always on
leds[0] = getColor(currentColor);
ledStates[0] = FULL_BRIGHT;
// Update the LEDs
FastLED.show();
prev_CLK_state = CLK_state;
// Check if the button is pressed
if (button.isPressed()) {
Serial.println("Button Pressed!"); // Print message when button is pressed
changeColor();
}
}
// Function to get the current color based on the state
CRGB getColor(ColorState colorState) {
switch (colorState) {
case RED: return CRGB::Red;
case BLUE: return CRGB::Blue;
case GREEN: return CRGB::Green;
case YELLOW: return CRGB::Yellow;
case CYAN: return CRGB::Cyan;
case PURPLE: return CRGB::Purple;
default: return CRGB::Black;
}
}
// Function to change the color state
void changeColor() {
currentColor = static_cast<ColorState>((currentColor + 1) % 6); // Cycle through RED, BLUE, GREEN
// Update all LEDs to the new color regardless of their state
for (int i = 0; i < NUM_LEDS; i++) {
// Change the color of the LED regardless of its state
if (leds[i].r == 0 && leds[i].g == 0 && leds[i].b == 0) {
// LED is off, just set its color without turning it on
leds[i] = getColor(currentColor).fadeToBlackBy(255); // Keep it off but set the color
} else if (ledStates[i] == HALF_BRIGHT) {
// LED is half-bright, change its color but keep it half-bright
leds[i] = getColor(currentColor).fadeToBlackBy(128); // Keep it at half brightness
} else {
// LED is fully bright, change its color
leds[i] = getColor(currentColor);
}
}
// Print the current color name
switch (currentColor) {
case RED: Serial.println("Current Color: RED"); break;
case BLUE: Serial.println("Current Color: BLUE"); break;
case GREEN: Serial.println("Current Color: GREEN"); break;
case YELLOW: Serial.println("Current Color: YELLOW"); break;
case CYAN: Serial.println("Current Color: CYAN"); break;
case PURPLE: Serial.println("Current Color: PURPLE"); break;
}
}](<#include %3CFastLED.h%3E
#include <ezButton.h> // the library to use for SW pin
#define CLK_PIN 2
#define DT_PIN 3
#define SW_PIN 4
#define LED_PIN 7
#define NUM_LEDS 14 // Set the number of LEDs in the ring + 1
#define BRIGHTNESS 255
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
ezButton button(SW_PIN); // create ezButton object that attach to SW_PIN
CRGB leds[NUM_LEDS];
enum ColorState {
RED,
BLUE,
GREEN,
YELLOW,
CYAN,
PURPLE
};
ColorState currentColor = RED;
int counter = 0; // Current LED index
int CLK_state;
int prev_CLK_state;
// Define LED states
enum LEDState {
OFF,
HALF_BRIGHT,
FULL_BRIGHT
};
LEDState ledStates[NUM_LEDS]; // Array to hold the state of each LED
void setup() {
Serial.begin(9600);
pinMode(CLK_PIN, INPUT);
pinMode(DT_PIN, INPUT);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
prev_CLK_state = digitalRead(CLK_PIN);
// Initialize all LEDs to off
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
ledStates[i] = OFF; // Set all LEDs to OFF state
}
// Set the first LED to be always on
leds[0] = getColor(currentColor); // Set the first LED to the current color
ledStates[0] = FULL_BRIGHT; // Set its state to FULL_BRIGHT
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
unsigned long lastDebounceTime = 0; // Last time the output pin was toggled
const unsigned long debounceDelay = 100; // Delay for debounce
void loop() {
button.loop(); // MUST call the loop() function first
CLK_state = digitalRead(CLK_PIN);
if (CLK_state != prev_CLK_state && (millis() - lastDebounceTime) > debounceDelay) {
lastDebounceTime = millis(); // Reset the debounce timer
int new_CLK_state = digitalRead(CLK_PIN);
if (new_CLK_state == CLK_state) { // Confirm the state is stable
lastDebounceTime = millis(); // Reset the debounce timer
if (digitalRead(DT_PIN) == LOW) {
// Counter-clockwise direction
if (counter > 0) { // Ensure counter does not go below 0
// Handle CCW logic
if (ledStates[counter] == FULL_BRIGHT) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to off
leds[counter] = CRGB::Black;
ledStates[counter] = OFF;
//} else if (ledStates[counter] == OFF) {
// Move to the previous LED and set to full brightness
counter--;
if(counter > NUM_LEDS) {
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
}
}
}
} else {
// Clockwise direction
if (counter < NUM_LEDS - 1) { // Ensure counter does not exceed NUM_LEDS - 1
// Handle CW logic
if (ledStates[counter] == OFF) {
// Set to half brightness
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
} else if (ledStates[counter] == HALF_BRIGHT) {
// Set to full brightness
leds[counter] = getColor(currentColor);
ledStates[counter] = FULL_BRIGHT;
} else if (ledStates[counter] == FULL_BRIGHT) {
// Move to the next LED and set to half brightness
counter++;
if (counter < NUM_LEDS) { // This check is now redundant but keeps the logic clear
leds[counter] = getColor(currentColor).fadeToBlackBy(128);
ledStates[counter] = HALF_BRIGHT;
}
}
}
}
Serial.print("COUNTER: ");
Serial.println(counter);
}
}
// Ensure the first LED is always on
leds[0] = getColor(currentColor);
ledStates[0] = FULL_BRIGHT;
// Update the LEDs
FastLED.show();
prev_CLK_state = CLK_state;
// Check if the button is pressed
if (button.isPressed()) {
Serial.println("Button Pressed!"); // Print message when button is pressed
changeColor();
}
}
// Function to get the current color based on the state
CRGB getColor(ColorState colorState) {
switch (colorState) {
case RED: return CRGB::Red;
case BLUE: return CRGB::Blue;
case GREEN: return CRGB::Green;
case YELLOW: return CRGB::Yellow;
case CYAN: return CRGB::Cyan;
case PURPLE: return CRGB::Purple;
default: return CRGB::Black;
}
}
// Function to change the color state
void changeColor() {
currentColor = static_cast<ColorState>((currentColor + 1) % 6); // Cycle through RED, BLUE, GREEN
// Update all LEDs to the new color regardless of their state
for (int i = 0; i < NUM_LEDS; i++) {
// Change the color of the LED regardless of its state
if (leds[i].r == 0 && leds[i].g == 0 && leds[i].b == 0) {
// LED is off, just set its color without turning it on
leds[i] = getColor(currentColor).fadeToBlackBy(255); // Keep it off but set the color
} else if (ledStates[i] == HALF_BRIGHT) {
// LED is half-bright, change its color but keep it half-bright
leds[i] = getColor(currentColor).fadeToBlackBy(128); // Keep it at half brightness
} else {
// LED is fully bright, change its color
leds[i] = getColor(currentColor);
}
}
// Print the current color name
switch (currentColor) {
case RED: Serial.println("Current Color: RED"); break;
case BLUE: Serial.println("Current Color: BLUE"); break;
case GREEN: Serial.println("Current Color: GREEN"); break;
case YELLOW: Serial.println("Current Color: YELLOW"); break;
case CYAN: Serial.println("Current Color: CYAN"); break;
case PURPLE: Serial.println("Current Color: PURPLE"); break;
}
}
-
Using an External Resistor:
- If you experience issues with signal integrity (e.g., flickering or erratic behavior), consider placing a 330-470 ohm resistor in series with the data line. This can help reduce signal reflections and improve reliability.
-
Capacitor Across Power Supply:
- Place a capacitor (e.g., 1000 µF, 6.3V or higher) across the power supply lines (VCC and GND) near the first LED to help smooth out power fluctuations.
Each WS2811 LED typically draws up to 60mA at full brightness.
For encoder:
Take from this datasheet: https://www.mouser.com/datasheet/2/54/PEL12T-777462.pdf
Resolution 024 = 24 Pulses per 360 ° Rotation
instead of the 100 ohms use 220 ohms! - wrong - i might have fried the green and blue from reverse polarity
https://cdn-shop.adafruit.com/datasheets/WS2811.pdf
Drawing 2024-12-02 10.45.33.excalidraw
Libraries and Resources
To facilitate control of WS2811 LEDs, several libraries are available for different platforms, including:
- Adafruit NeoPixel Library: For Arduino and compatible platforms.
- FastLED Library: Supports a wide range of LED types, including WS2811.
- rpi-ws281x: For controlling WS2811 LEDs on Raspberry Pi.
To flash the Daisy Seed microcontroller with Arduino code through Visual Studio Code (VSCode), you can set up the environment as follows:
1. Install PlatformIO
- Open VSCode.
- Install the PlatformIO IDE extension from the Extensions Marketplace.
- After installation, PlatformIO will initialize a workspace.
2. Install DaisyDuino and STM32 Support
- Open the PlatformIO Home screen by clicking the small house icon in the bottom-left corner.
- Go to Platforms > Embedded.
- Search for ST STM32 and install it.
- Install the DaisyDuino library:
- Go to Libraries in PlatformIO.
- Search for DaisyDuino and install it into your project.
3. Set Up a New Project
- Click New Project in PlatformIO.
- Configure the project:
- Board: Choose a board with an STM32F405RG chip (e.g., "Generic STM32F405RG").
- Framework: Choose Arduino.
- Location: Select a folder for your project.
- Click Finish to create the project.
4. Configure Project Environment
Modify the platformio.ini
file in your project root to include settings specific to the Daisy Seed:
[env:daisy_seed] platform = ststm32 board = genericSTM32F405RG framework = arduino upload_protocol = dfu monitor_speed = 115200 lib_deps = electro-smith/DaisyDuino
5. Prepare Daisy Seed for DFU Mode
The Daisy Seed must be in DFU (Device Firmware Upgrade) mode for uploading:
- Press and hold the BOOT button on the Daisy Seed.
- While holding BOOT, press and release the RESET button.
- Release the BOOT button. The device should now be in DFU mode.
6. Write Your Code
- Open the
src/main.cpp
file in your project. - Write your Arduino code here. For example:
#include "DaisyDuino.h" DaisySeed hw; void setup() { hw.Configure(); hw.Init(); hw.StartLog(true); Serial.println("Hello, Daisy!"); } void loop() { // Your main code here }
7. Build and Upload
- To build your code, click the checkmark icon in the bottom-left corner (PlatformIO: Build).
- To upload your code to the Daisy Seed, click the arrow icon (PlatformIO: Upload).
- Ensure the Daisy Seed is in DFU mode before uploading.
8. Monitor Serial Output
- Open the Serial Monitor in PlatformIO by clicking the plug icon or running the "Monitor" task.
- Check your Daisy Seed's output or debug via serial.
9. Test Your Setup
After uploading, the Daisy Seed should execute your Arduino sketch. Use examples from DaisyDuino to confirm everything works.
This setup combines the power of VSCode and PlatformIO, providing better debugging and build tools compared to the Arduino IDE. Let me know if you encounter any issues!
https://hackaday.io/project/171841-driveralgorithm-for-360-deg-endless-potentiometer
https://forum.electro-smith.com/t/endless-potentiometer-decoding/3972