#include <Adafruit_NeoPixel.h>
#define LED_PIN 16
#define LED_COUNT 16
#define BUTTON_PIN 5 // Pushbutton connected to pin 5
#define BUZZER_PIN 19 // Buzzer connected to pin 19
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
const int pins[] = {23, 22, 2, 15, 18, 21, 4}; // 7-segment display pins (A, B, C, D, E, F, G)
const int data[10][7] = {
{0, 0, 0, 0, 0, 0, 1}, // 0
{1, 0, 0, 1, 1, 1, 1}, // 1
{0, 0, 1, 0, 0, 1, 0}, // 2
{0, 0, 0, 0, 1, 1, 0}, // 3
{1, 0, 0, 1, 1, 0, 0}, // 4
{0, 1, 0, 0, 1, 0, 0}, // 5
{0, 1, 0, 0, 0, 0, 0}, // 6
{0, 0, 0, 1, 1, 1, 1}, // 7
{0, 0, 0, 0, 0, 0, 0}, // 8
{0, 0, 0, 0, 1, 0, 0} // 9
};
const int switchPin = 14; // Button pin
int currentValue = 0;
int direction = 1; // 1 for up, -1 for down
int switchState;
int lastSwitchState = HIGH;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP); // Set button pin as input with pull-up resistor
pinMode(BUZZER_PIN, OUTPUT); // Set buzzer pin as output
Serial.begin(115200);
Serial.println("Hello, ESP32!");
strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(250); // Set brightness to about 1/5 (max = 255)
for (int x = 0; x < 7; x++) {
pinMode(pins[x], OUTPUT);
}
pinMode(switchPin, INPUT_PULLUP);
}
void loop() {
if(digitalRead(BUTTON_PIN) == LOW) { // Button is pressed
tone(BUZZER_PIN, 2300); // Turn on buzzer with a 2300 Hz tone
colorWipe(strip.Color(255, 0, 0), 20); // Red color for NeoPixel
colorWipe(strip.Color( 0, 255, 0), 15); // Green
colorWipe(strip.Color( 0, 0, 255), 00); // Blue
}
else { // Button is not pressed
noTone(BUZZER_PIN); // Turn off the buzzer
strip.clear(); // Turn off all NeoPixels
strip.show(); // Update the strip to reflect changes
}
delay(10); // Short delay for debounce
switchState = digitalRead(switchPin);
if (switchState == LOW && lastSwitchState == HIGH) { // Detect button press
currentValue += direction;
// Change direction at boundaries (0 and 9)
if (currentValue == 9) {
direction = -1;
} else if (currentValue == 0) {
direction = 1;
}
Serial.println(currentValue);
delay(150); // Debounce delay
}
// Update the 7-segment display
for (int x = 0; x < 7; x++) {
digitalWrite(pins[x], data[currentValue][x]);
}
lastSwitchState = switchState;
}
void colorWipe(uint32_t color, int wait) {
for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
//basics actuators
//sensors
//Wifi
//thinkSpeak
//blynk
//thinksBoard
//thinkEsp - Twillio
//whatsApp, telegram
//NodeRed
//Esp / Arduino Cloud
//Rasberry pi - Install debian os
// Deep learning task
//Mobile App - pass data to firebase
//mobile - smart cam app