Project #11: ESP32 Feather – Push Button – Mk02
ESP32 Feather – Push Button – Mk02
——
——
——
——
——
——
Momentary Pushbutton Switch
This is a standard 12mm square momentary button. What we really like is the large button head and good tactile feel (it ‘clicks’ really well). This button is great for user input on a PCB or a good, big reset button on a breadboard. Breadboard friendly!
DonLuc1908Mk02
1 x Adafruit HUZZAH32 ESP32 Feather
1 x Adafruit SHARP Memory Display
1 x LED Green
1 x Push Button
1 x 100 Ohm
1 x 10K Ohm
12 x Jumper Wires 3″ M/M
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
Adafruit HUZZAH32 ESP32 Feather
LG1 – Digital 21
PB1 – Digital 17
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
GND – GND
VIN – +3.3V
Follow Us
Web: http://neosteamlabs.com/
Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
DL1908Mk02p.ino
// ***** Don Luc Electronics ***** // Software Version Information // Project #11: HUZZAH32 ESP32 Feather - Push Button - Mk02 // 08-02 // DonLuc1908Mk02p.ino 08-02 // Adafruit HUZZAH32 ESP32 Feather Board // SHARP Display // LED Green // Push Button // include Library Code #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // SHARP Memory Display // any pins can be used #define SHARP_SCK 13 #define SHARP_MOSI 12 #define SHARP_SS 27 // Set the size of the display here, e.g. 144x168! Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168); // The currently-available SHARP Memory Display (144x168 pixels) // requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno // or other <4K "classic" devices! #define BLACK 0 #define WHITE 1 int minorHalfSize; // 1/2 of lesser of display width or height // LED Green int iLEDGreen = 21; // LED Green int stateLEDGreen = LOW; // stateLEDGreen // Button int iBut1 = 17; // Button 1 int ButState1; // Variable for reading the button status int previous = LOW; // previous long lTime = 0; // lTime long debounce = 500; // debounce void loop() { // Read the state of the button value ButState1 = digitalRead(iBut1); // Check if the button is pressed if (ButState1 == HIGH && previous == LOW && millis() - lTime > debounce) { if(stateLEDGreen == HIGH) { // stateLEDGreen = LOW stateLEDGreen = LOW; // SHARP Memory Display Off isDisplayOff(); } else { // stateLEDGreen = HIGH stateLEDGreen = HIGH; // SHARP Memory Display On isDisplayOn(); } lTime = millis(); } // iLEDGreen digitalWrite(iLEDGreen, stateLEDGreen); previous == ButState1; }
getDisplay.ino
// SHARP Memory Display On void isDisplayOn() { // Clear Display display.clearDisplay(); // text display tests display.setRotation(4); //display.clearDisplay(); display.setTextSize(5); display.setTextColor(BLACK); display.setCursor(10,25); display.println("LED"); display.setCursor(10,75); display.println("On"); display.refresh(); } // SHARP Memory Display Off void isDisplayOff() { // Clear Display display.clearDisplay(); // text display tests display.setRotation(4); //display.clearDisplay(); display.setTextSize(5); display.setTextColor(BLACK); display.setCursor(10,25); display.println("LED"); display.setCursor(10,75); display.println("Off"); display.refresh(); }
setup.ino
// Setup void setup() { // SHARP Display start & clear the display display.begin(); display.clearDisplay(); // Button 1 // Initialize the button as an input pinMode(iBut1, INPUT); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); }
Don Luc
Leave a Reply