Last active
March 19, 2024 08:29
-
-
Save ueponx/65f0fa39ce03b840d4dad2c241b61083 to your computer and use it in GitHub Desktop.
SORACOM LTE-M Button Plus と Seeed Studio XIAO SAMD21のArduinoでのプログラミング
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define OUT_PIN 0 | |
// #define LED_PIN 13 | |
#define BUTTON_PIN 2 | |
#define PIXEL_PIN 3 | |
#define PIXEL_COUNT 1 | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); | |
bool oldState = LOW; | |
// const int OUT_PIN = 0; // the number of the pushbutton pin | |
// const int LED_PIN = 13; // the number of the LED pin | |
//int buttonState = 0; // variable for reading the pushbutton status | |
void setup() { | |
// pinMode(LED_PIN, OUTPUT); | |
pinMode(OUT_PIN, OUTPUT); | |
digitalWrite(OUT_PIN, LOW); | |
pinMode(BUTTON_PIN, INPUT_PULLUP); | |
strip.begin(); | |
strip.clear(); | |
strip.show(); | |
} | |
void loop() { | |
bool newState = digitalRead(BUTTON_PIN); | |
if (newState == HIGH && oldState == LOW) { | |
delay(20); | |
newState = digitalRead(BUTTON_PIN); | |
if (newState == HIGH) { | |
strip.setPixelColor(0, strip.Color(255, 0, 0)); | |
strip.show(); | |
// digitalWrite(LED_PIN, HIGH); | |
digitalWrite(OUT_PIN, HIGH); | |
delay(200); | |
// digitalWrite(LED_PIN, LOW); | |
digitalWrite(OUT_PIN, LOW); | |
delay(150); | |
strip.clear(); | |
strip.show(); | |
} | |
} | |
oldState = newState; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment