Skip to content

Commit

Permalink
Add neopixel code
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Damiano <[email protected]>
  • Loading branch information
SRGDamia1 committed Dec 4, 2024
1 parent f8cc5e2 commit 7ee23e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ If no epoch start is given, it is assumed to be UNIX (January 1, 1970).
- Storing _buttonPinMode internally.
- Added a single define (`MS_OUTPUT`) to use for all outputs from ModularSensors.
- Added support for sending printouts and debugging to two different serial ports. This is useful for devices (like SAMD) that use a built in USB serial port which is turned off when the device sleeps. If `MS_2ND_OUTPUT` is defined, output will go to *both* `MS_2ND_OUTPUT` and to `MS_OUTPUT`.
- Added example code for flashing neopixel in the menu example.

### Removed

Expand Down
41 changes: 34 additions & 7 deletions examples/menu_a_la_carte/menu_a_la_carte.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3095,8 +3095,39 @@ UbidotsPublisher ubidots(dataLogger, &modem.gsmClient, ubidotsToken,
// Working Functions
// ==========================================================================
/** Start [working_functions] */

#if defined(PIN_NEOPIXEL)
#include <Adafruit_NeoPixel.h>
// Declare our NeoPixel strip object:
Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL);
// Flashes the LED's on the primary board
void greenredflash(uint8_t numFlash = 4, uint8_t rate = 75) {
void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) {
#if defined(PIN_NEOPIXEL_POWER)
pinMode(PIN_NEOPIXEL_POWER, OUTPUT);
digitalWrite(PIN_NEOPIXEL_POWER, HIGH);
#endif
for (uint8_t i = 0; i < numFlash; i++) {
pixels.setPixelColor(i, pixels.Color(0, 255, 0)); // set to green
pixels.show(); // Send the updated pixel colors to the hardware.
delay(rate);
pixels.setPixelColor(i, pixels.Color(255, 0, 0)); // set to red
pixels.show(); // Send the updated pixel colors to the hardware.
delay(rate);
}
pixels.clear(); // Set all pixel colors to 'off'
#if defined(PIN_NEOPIXEL_POWER)
digitalWrite(PIN_NEOPIXEL_POWER, LOW);
#endif
}
#else
// Flashes the LED's on the primary board
void greenRedFlash(uint8_t numFlash = 4, uint8_t rate = 75) {
// Set up pins for the LED's
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED, LOW);
pinMode(redLED, OUTPUT);
digitalWrite(redLED, LOW);
// Flash the lights
for (uint8_t i = 0; i < numFlash; i++) {
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
Expand All @@ -3107,6 +3138,7 @@ void greenredflash(uint8_t numFlash = 4, uint8_t rate = 75) {
}
digitalWrite(redLED, LOW);
}
#endif

// Uses the processor sensor object to read the battery voltage
// NOTE: This will actually return the battery level from the previous update!
Expand All @@ -3125,13 +3157,8 @@ float getBatteryVoltage() {
// ==========================================================================
void setup() {
/** Start [setup_flashing_led] */
// Set up pins for the LED's
pinMode(greenLED, OUTPUT);
digitalWrite(greenLED, LOW);
pinMode(redLED, OUTPUT);
digitalWrite(redLED, LOW);
// Blink the LEDs to show the board is on and starting up
greenredflash();
greenRedFlash(3, 35);
/** End [setup_flashing_led] */

/** Start [setup_wait] */
Expand Down

1 comment on commit 7ee23e3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All sensor and variable subclasses must be included in the Menu a la Carte example
missing_menu_docs

Please sign in to comment.