Page 1 of 1

ESP32 Blinky Code

Posted: Sat Mar 04, 2017 5:20 pm
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);
}

Re: ESP32 Blinky Code

Posted: Wed May 03, 2017 9:05 am
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);
}