Skip to content

Instantly share code, notes, and snippets.

@elktros
elktros / ESP32-BLE-Server.ino
Created March 24, 2021 13:37
ESP32 BLE Server
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
@elktros
elktros / Raspberry-Pi-Pico-UART-CMakeLists.txt
Created March 22, 2021 12:58
Raspberry Pi Pico UART Serial CMakeLists
add_executable(hello_serial
hello_serial.c
)
# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(hello_serial pico_stdlib)
# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(hello_serial)
@elktros
elktros / Raspberry-Pi-Pico-USB-CMakeLists.txt
Created March 22, 2021 12:56
Raspberry Pi Pico USB Serial CMakeLists
if (TARGET tinyusb_device)
add_executable(hello_usb
hello_usb.c
)
# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(hello_usb pico_stdlib)
# enable usb output, disable uart output
pico_enable_stdio_usb(hello_usb 1)
@elktros
elktros / Raspberry-Pi-Pico-Hello-World.c
Created March 22, 2021 12:40
Code for printing Hello World on Raspberry Pi Pico's serial (USB).
**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
int main() {
@elktros
elktros / Bluetooth-Controlled-LED-ESP32.ino
Created March 19, 2021 19:04
Code for Bluetooth Controlled LED using ESP32.
#include <BluetoothSerial.h>
#define ledPIN 2
BluetoothSerial SerialBT;
byte BTData;
/* Check if Bluetooth configurations are enabled in the SDK */
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
@elktros
elktros / ESP32-Bluetooth-Classic-Serial.ino
Created March 19, 2021 18:26
Simple BluetoothSerial to Serial Communication in ESP32.
#include "BluetoothSerial.h"
/* Check if Bluetooth configurations are enabled in the SDK */
/* If not, then you have to recompile the SDK */
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
@elktros
elktros / ESP32-Web-Controlled-Servo.ino
Created March 17, 2021 11:30
Code for ESP32 Web Controlled Servo.
#include <WiFi.h>
const int servoPin = 16; /* GPIO16 */
const char* ssid = "ESP32-WiFi"; /* Add your router's SSID */
const char* password = "12345678"; /*Add the password */
int dutyCycle = 0;
//int position1 = 0;
@elktros
elktros / ESP32-Servo-POT.ino
Created March 17, 2021 11:27
Control Servo Motor using ESP32 and Potentiometer.
#define ADCPIN A0
const int redLEDPin = 16; /* GPIO16 */
int dutyCycle = 0;
int adcValue;
/* Setting PWM properties */
const int PWMFreq = 50;
@elktros
elktros / ESP32-Servo-Sweep.ino
Created March 17, 2021 11:25
Sweep program for ESP32 Servo Control.
/* ESP32 Servo Sweep */
const int servoPin = 16; /* GPIO16 */
int dutyCycle = 0;
/* Setting PWM properties */
const int PWMFreq = 50;
const int PWMChannel = 0;
const int PWMResolution = 8;
//const int MAX_DUTY_CYCLE = (int)(pow(2, PWMResolution) - 1);
@elktros
elktros / ESP32-Servo-Serial.ino
Created March 17, 2021 11:05
Control Servo Motor using ESP32 and Serial Input.
const int servoPin = 16; /* GPIO16 */
int dutyCycle = 0;
/* Setting PWM properties */
const int PWMFreq = 50;
const int PWMChannel = 0;
const int PWMResolution = 8;
//const int MAX_DUTY_CYCLE = (int)(pow(2, PWMResolution) - 1);