ESP32 Blinky Code

Schematics, Example Code and Q&A

ESP32 Blinky Code

Postby Daniel » Sat Mar 04, 2017 5:20 pm

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

The WiFi example listed here https://learn.sparkfun.com/tutorials/esp32-thing-hookup-guide#arduino-example-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 38 times
Daniel
 
Posts: 91
Joined: Tue Nov 13, 2012 2:10 pm

Re: ESP32 Blinky Code

Postby vandys » Wed May 03, 2017 9:05 am

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);
}
vandys
 
Posts: 4
Joined: Tue May 02, 2017 10:03 pm


Return to ESP32 Related

Who is online

Users browsing this forum: No registered users and 1 guest

cron