Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Example: Integrating Brake Signal with LED Control on ESP32-C3 #28

Open
oangelo opened this issue Apr 10, 2024 · 1 comment

Comments

@oangelo
Copy link

oangelo commented Apr 10, 2024

Hello VESC Express Team,

I've recently embarked on a journey to learn and experiment with VESC Express, starting with a DIY setup based on the ESP32-C3 Super Mini. As a beginner, I was hoping to find straightforward examples to kickstart my project, similar to the basic "blink" LED examples found in many development environments.

While I successfully implemented a simple LED blink program on GPIO 8, I'm aiming to delve into more complex scenarios. Specifically, I'm interested in controlling the LED (connected to GPIO 8 of the ESP32-C3) based on the brake signal's state, intending to turn on the LED whenever the brake is applied.

This functionality, I believe, would not only serve my learning curve but could also benefit others in the community, providing a practical example of integrating VESC's control signals with external hardware actions.

Below is the "blink" example I've managed to implement, which I'm sharing in the hopes it might assist someone else starting out:

;; Configure GPIO 8 as an output
(print "Start")
(gpio-configure 8 'pin-mode-out)
(gpio-write 8 1)

;; Define a recursive function to blink the LED without using `loop`
(defun blink-led ()(progn
  (gpio-write 8 1) ;; Turn LED on
  (print "led on")
  (sleep 1)     ;; Wait for 1000 milliseconds (1 second)
  (gpio-write 8 0) ;; Turn LED off
  (print "led off")
  (sleep 1)     ;; Wait for 1000 milliseconds (1 second)
  (blink-led)))     ;; Recursively call blink-led to continue the loop

;; Call the blink-led function to start blinking the LED
(blink-led)
@oangelo
Copy link
Author

oangelo commented Apr 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant