Advertisement
microrobotics

ESP32 C3 Mini Dev Board

Oct 24th, 2022 (edited)
5,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //    For the Robotics.org.za  ESP32-C3 Mini-1 development board //    By Pieter from Innovation Instruments //
  2.  
  3. #include <stdio.h>
  4.  
  5. #define Red_LED 3        // rgb led pins, active low
  6. #define Green_LED 4
  7. #define Blue_LED 5
  8. #define LED 21            // onboard blue led
  9.  
  10. unsigned int  Loop_Count = 0;
  11.  
  12. //
  13. // Setup
  14. //
  15. void setup() // put your setup code here, to run once:
  16. {
  17.    pinMode(LED,OUTPUT);
  18.    pinMode(Red_LED,OUTPUT);
  19.    pinMode(Green_LED,OUTPUT);
  20.    pinMode(Blue_LED,OUTPUT);
  21.    digitalWrite(Red_LED,HIGH);
  22.    digitalWrite(Green_LED,HIGH);
  23.    digitalWrite(Blue_LED,HIGH);
  24. }
  25. //
  26. // main loop
  27. //
  28. void loop()   // put your main code here, to run repeatedly:
  29. {
  30.    digitalWrite(LED,HIGH);
  31.    delay(200);
  32.    digitalWrite(LED,LOW);
  33.    delay(200);
  34.  
  35.    Loop_Count++;
  36.    if (Loop_Count == 3)
  37.    {
  38.      digitalWrite(Red_LED,LOW);    // on
  39.      digitalWrite(Green_LED,HIGH);
  40.      digitalWrite(Blue_LED,HIGH);
  41.    }
  42.    else if (Loop_Count == 6)
  43.    {
  44.      digitalWrite(Red_LED,HIGH);
  45.      digitalWrite(Green_LED,LOW);   // on
  46.      digitalWrite(Blue_LED,HIGH);
  47.    }
  48.    else if (Loop_Count == 9)
  49.    {
  50.      digitalWrite(Red_LED,HIGH);
  51.      digitalWrite(Green_LED,HIGH);
  52.      digitalWrite(Blue_LED,LOW);   // on
  53.      Loop_Count = 0;
  54.    }
  55.    else                            // all off
  56.    {
  57.      digitalWrite(Red_LED,HIGH);
  58.      digitalWrite(Green_LED,HIGH);
  59.      digitalWrite(Blue_LED,HIGH);
  60.    }
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement