Hello,
I am investigating using the ESP32 Pico-Kit dev board. It uses the ESP32 Pico D4 chip. I have uploaded a simple program to blink the builtin led, report some hall effect values and touch pin values. When I run the program, the hall functions and touch pin function work, but the builtin led does not blink??? Any hints on how I can make it blink, meaning control whether the led is on or off?
I believe that I found the builtin led on this board is controlled via GPIO2. That is what I am using in my sketch. Here is my code.
#include <Arduino.h>
#include <Adafruit_Sleepydog.h>
#include <ESP32Time.h>
#include <esp_sleep.h>
int shrt;
int lng;
int hall;
int halltotal;
int touchValue;
int touchpin = 4;
int touchtotal;
void shortblink(int blinks);
void longblink(int blinks);
// Define the touchpad sensitivity
#define Threshold 20
// Define the buil in LED as pin 2
#define LED_BUILTIN 2
// Function reference for a wake callback function
void touchCallback();
void setup() {
Serial.begin(9600);
Serial.println("");
Serial.println("... Waking from deep sleep ...");
Serial.println("");
// Set up the deep sleep timmer to sleep for 30 seconds
esp_sleep_enable_timer_wakeup(1000000 * 18.52);
// Enable the touch pad functin as a wake up source
esp_sleep_enable_touchpad_wakeup();
// Now call the function for touchpad wake up
touchAttachInterrupt(4, touchCallback, Threshold);
// initialize LED digital pin as an output.
pinMode (LED_BUILTIN, OUTPUT);
digitalWrite (LED_BUILTIN, LOW);
// assign beginning values short and long variables
shrt = 3;
lng = 1;
}
void loop() {
// Call function to perform the 1st short blinks
shortblink(shrt);
delay(500);
// Second loop to blink long blinks.
longblink(lng);
delay(500);
// Call function to perform the 2nd short blinks
shortblink(shrt);
delay(500);
// Read the builtin ESP32 hall effect sensor value
// Then print it to the serial port 5 times
hall = 0;
halltotal = 0;
for (int i=0; i<5; i++) {
hall = hallRead();
halltotal = hall + halltotal;
Serial.print("hall effect reading is ");
Serial.println(hall);
}
// Calcualte and print the average hall value
delay(1000);
hall = halltotal / 5;
Serial.println("");
Serial.print("Average hall value = ");
Serial.println(hall);
Serial.println("");
delay(100);
// Read 5 touch values and average them
touchValue = 0;
touchtotal = 0;
for (int i=0; i<5; i++) {
touchValue = touchRead(touchpin);
touchtotal = touchtotal + touchValue;
}
touchValue = touchtotal / 5;
Serial.print("Average Touch value = ");
Serial.println(touchValue);
Serial.println("");
delay(100);
// Put the program to sleep for 30 seconds
//Note, wake up is a complete reboot
Serial.println(" ... Entering deep sleep mode ...");
Serial.flush();
esp_deep_sleep_start();
}
void shortblink(int blinks) {
for (int i=0; i<blinks; i++) {
digitalWrite (LED_BUILTIN, HIGH);
delay(100);
digitalWrite (LED_BUILTIN, LOW);
delay(100);
}
}
void longblink(int blinks) {
for (int i=0; i<blinks; i++) {
digitalWrite (LED_BUILTIN, HIGH);
delay(500);
digitalWrite (LED_BUILTIN, LOW);
delay(500);
}
}
// The function definition for the wake up callback
void touchCallback() {
// Leave blank
// By default the blank function restarts program from beginning
}
esp32 Pico kit builtin LED
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: esp32 Pico kit builtin LED
Looking at the schematic, that board only has one LED and it's permanently on as it's hardwired into the power supply. If you want a LED to blink, you should provide one yourself.
Who is online
Users browsing this forum: No registered users and 125 guests