ESP32 Blinky Code

Schematics, Example Code and Q&A
Daniel
Posts: 133
Joined: Tue Nov 13, 2012 2:10 pm

ESP32 Blinky Code

Unread post by Daniel »

This code is loaded on the bords before they are shipped.

The WiFi example listed here https://learn.sparkfun.com/tutorials/es ... ample-wifi works on the board. The button to the left of the Micro-USB connector works as the button in the description.

Daniel

Code: Select all

/*
   This example code is in the public domain.

 */
 
#define RLED 16
#define GLED 17
#define BLED 18


void setup() {
  pinMode(RLED, OUTPUT);
  pinMode(GLED, OUTPUT);
  pinMode(BLED, OUTPUT);
}


void loop() {
  digitalWrite(RLED, LOW);
  delay(1000);
  digitalWrite(RLED, HIGH);
  delay(1000);
  digitalWrite(GLED, LOW);
  delay(1000);
  digitalWrite(GLED, HIGH);
  delay(1000);
  digitalWrite(BLED, LOW);
  delay(1000);
  digitalWrite(BLED, HIGH);
  delay(1000);
}
Attachments
ESP32_RGBBlink.zip
(353 Bytes) Downloaded 419 times
vandys
Posts: 4
Joined: Tue May 02, 2017 10:03 pm

Re: ESP32 Blinky Code

Unread post by vandys »

Similar function within the Espressif compilation environment:

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

#define RLED 16
#define GLED 17
#define BLED 18

void
setup()
{
int x;

for (x = RLED; x <= BLED; ++x) {
gpio_pad_select_gpio(x);
gpio_set_direction(x, GPIO_MODE_OUTPUT);
}
}


void
blink_task(void *pvParameter)
{
int x;

setup();
for (x = RLED; x <= BLED; ++x) {
gpio_set_level(x, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(x, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}

void
app_main()
{
xTaskCreate(&blink_task, "blink_task", 512, NULL, 5, NULL);
}
Post Reply